Content API Tutorial
In this tutorial, we'll learn how to upload content to the Content Store API and how to retrieve it.
Prepare the Content
Create a file containing a JSON dictionary, mapping contentId to a JSON blob. For bulk uploads, ensure this batch has fewer than 100 records.
echo '{"testid": {"name": "Content Test"}}' > /tmp/contentbatch.json
Upload the Content
Use the following CURL command to upload the content to the Content Store.
curl "https://{yourcontenturl}.promoted.ai/v1/content/batch?source=default" -XPUT -H "Content-Type: application/json" --data "@/tmp/contentbatch.json" -H 'x-api-key: $API_KEY'
Expected Response: HTTP status code of 200.
Note: This will save the items with a source named default
. The Content Store allows writing separate documents per source
for the same content ID. This capability enables multiple writers to write content data without coordination. Refer to the Sources documentation for an in-depth understanding.
Caution: The API key might contain non-alphanumeric characters. Depending on the shell you're using, be cautious about how you quote it.
Retrieve the Test Document
Use the CURL command below to fetch the test document.
curl "https://{yourcontenturl}.promoted.ai/v1/content/testid?source=default" -H "Content-Type: application/json" -H 'x-api-key: $API_KEY'
Expected Response: HTTP status code of 200.
Expected Response Body:
{"name":"Dan Test"}
Updated 20 days ago