Example curl Call
curl is a command-line tool for transferring data to or from a server via HTTP.
You can use curl to send data to, and to download generated text from, your project’s published endpoint. If you use a Mac, you probably have curl installed already. If you use a Windows computer with an OS older than Windows 10, you may need to download and install it.
The prerequisites for a curl call are:
The URL for your project — see Publishing a project
Your generated API key — see Publish View > API key
A request body file — see Using the API > The request body
The following is an example curl call:
curl -i -X POST --header "content-type: application/json;charset=UTF-8" --header "Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiIzZWYtWE1PaDN6LTBpa1NEM2wzOG1XbkgiLCJpYXQiOjE1MjA1OTYzODksImV4cCI6MTY3OLo3NjM4OSwiaXNzIjoiQUxpdGUiLCJzdWIiOiJfZm02SmIzQl9hQWIiLCJBuGl0ZS5wZXJtIjpbInByczp4OmJCTVlaYm5Famp5Il0sIkFMaXRlLnR0IjoidV9hIn0.PKjBxiTDxcy15yfHYKkbxVjVtzW1VdI1uwG_hDrQzachsrQOlS5yBgqQNdkyz3Bq1ONqnh7mLrboldH_uxje4A" -d @RequestBody.json https://app.studio.arria.com:443/alite_content_generation_webapp/text/bBTZZbnEpjy
Important
The command should contain no line breaks.
The command has the following options and parameters:
-i means include protocol headers in the output.
-X means specify a request command to use.
POST is the request command (it means to perform an HTTP POST action).
"content-type: application/json;charset=UTF-8" is the type of content.
--header means pass the custom information that follows to the server.
"Authorization: Bearer followed by the long API key is for authentication.
-d is the option for the data for the HTTP POST.
@RequestBody.json is the request body file in the current directory — that is, a file containing the request body JSON for your project. Please refer to Using the API > Request body examples, which shows the format for each Studio project type.
https://app.studio.arria.com:443/alite_content_generation_webapp/text/bBTZZbnEpjy is the URL of the project’s endpoint.
Your curl call should return a response that looks like this:
HTTP/1.1 200 is an HTTP response status code indicating that the request has succeeded (note: HTTP/2 200 also means success).
If the call to the API endpoint is unsuccessful, the HTTP code will be one other than 200:
If you receive a code other than 200 and the accompanying error message is unclear, consult a resource such as Mozilla's HTTP response status codes for guidance.
Tip
If you want the narrative output in plain text format rather than HTML format, set the contentOutputFormat
property to “TEXT” in your request body file. See Request body options for guidance and examples.