What should my request body be in the following API request?
API requestPOST https://private-anon-xxxxxxxx-apify2prod.apiary-proxy.com/v2/actor-tasks/testttt~hedge-funds-scraper/run-sync?token=XXXXX
Request Headers
content-type: application/json
content-length: 18
Request Body
{
"bar": "foo"
}
My goal is to run a task remotely by sending a server request using the Apify API. Here is the documentation I'm referencing for my API call.
The result I expect is a server response that includes the same dataset I get when I run the task manually. Specifically, that dataset looks as follows.
Expected result[{
"url": "https://en.wikipedia.org/wiki/List_of_hedge_funds",
"pageTitle": "List of hedge funds - Wikipedia",
"links": [
{
"firmName": "Bridgewater Associates",
"firmUrl": "/wiki/Bridgewater_Associates",
"hq": "Westport, CT",
"hqUrl": "/wiki/United_States",
"aum": "$132,050"
},
{
"firmName": "Renaissance Technologies",
"firmUrl": "/wiki/Renaissance_Technologies",
"hq": "East Setauket, NY",
"hqUrl": "/wiki/United_States",
"aum": "$110,000"
},
{
"firmName": "Man Group",
"firmUrl": "/wiki/Man_Group",
"hq": "London",
"hqUrl": "/wiki/United_Kingdom",
"aum": "$62,000"
},
{
"firmName": "AQR Capital Management",
"firmUrl": "/wiki/AQR_Capital_Management",
"hq": "Greenwich, CT",
"hqUrl": "/wiki/United_States",
"aum": "$60,840"
},
{
"firmName": "Two Sigma Investments",
"firmUrl": "/wiki/Two_Sigma_Investments",
"hq": "New York City, NY",
"hqUrl": "/wiki/United_States",
"aum": "$42,900"
},
{
"firmName": "Millennium Management",
"firmUrl": "/wiki/Millennium_Management,_LLC",
"hq": "New York City, NY",
"hqUrl": "/wiki/United_States",
"aum": "$38,776"
},
{
"firmName": "Elliott Management",
"firmUrl": "/wiki/Elliott_Management",
"hq": "New York City, NY",
"hqUrl": "/wiki/United_States",
"aum": "$37,769"
},
{
"firmName": "BlackRock",
"firmUrl": "/wiki/BlackRock",
"hq": "New York City, NY",
"hqUrl": "/wiki/United_States",
"aum": "$32,909"
},
{
"firmName": "Citadel LLC",
"firmUrl": "/wiki/Citadel_LLC",
"hq": "Chicago, IL",
"hqUrl": "/wiki/United_States",
"aum": "$32,243"
},
{
"firmName": "Davidson Kempner Capital Management",
"firmUrl": "/wiki/Davidson_Kempner_Capital_Management",
"hq": "New York City, NY",
"hqUrl": "/wiki/United_States",
"aum": "$30,880"
},
{
"firmName": "Viking Global Investors",
"firmUrl": "/wiki/Viking_Global_Investors",
"hq": "Greenwich, CT",
"hqUrl": "/wiki/United_States",
"aum": "$30,000"
},
{
"firmName": "Baupost Group",
"firmUrl": "/wiki/Baupost_Group",
"hq": "Boston, MA",
"hqUrl": "/wiki/United_States",
"aum": "$28,900"
},
{
"firmName": "D.E. Shaw & Co.",
"firmUrl": "/wiki/D.E._Shaw_%26_Co.",
"hq": "New York City, NY",
"hqUrl": "/wiki/United_States",
"aum": "$28,676"
},
{
"firmName": "Farallon Capital",
"firmUrl": "/wiki/Farallon_Capital",
"hq": "San Francisco, CA",
"hqUrl": "/wiki/United_States",
"aum": "$27,600"
},
{
"firmName": "Marshall Wace",
"firmUrl": "/wiki/Marshall_Wace",
"hq": "London",
"hqUrl": "/wiki/United_Kingdom",
"aum": "$27,100"
},
{
"firmName": "The Children's Investment Fund Management",
"firmUrl": "/wiki/The_Children%27s_Investment_Fund_Management",
"hq": "London",
"hqUrl": "/wiki/United_Kingdom",
"aum": "$27,100"
},
{
"firmName": "Wellington Management Company",
"firmUrl": "/wiki/Wellington_Management_Company",
"hq": "Boston, MA",
"hqUrl": "/wiki/United_States",
"aum": "$22,000"
},
{
"firmName": "Winton Group",
"firmUrl": "/wiki/Winton_Group",
"hq": "London",
"hqUrl": "/wiki/United_Kingdom",
"aum": "$22,100"
},
{
"firmName": "Capula Investment Management",
"firmUrl": "/wiki/Capula_Investment_Management",
"hq": "London",
"hqUrl": "/wiki/United_Kingdom",
"aum": "$19,800"
},
{
"firmName": "York Capital Management",
"firmUrl": "/wiki/York_Capital_Management",
"hq": "New York City, NY",
"hqUrl": "/wiki/United_States",
"aum": "$18,500"
}
]
}]
Below is a screenshot of the actual result I am getting. Notice the 201 response code and the highlighted portion of the response body that says:
Actual result
{ bar: 'foo' }
What am I doing wrong? What should my request body be?
Make sure you specified the outputRecordKey
correctly in the URL parameters. It needs to match some key produced by the actor and present in the key-value store. Note that you will only be able to access the key-value store this way but not the dataset. If you need to get data from the default dataset then you'll need to query it manually after the run or choose to run asynchronously and use the information from the response to locate the dataset. Check out these endpoints in docs:
https://docs.apify.com/api/v2#/reference/actor-tasks/last-run-object-and-its-storages