Content types
Most Infobip API requests and responses use application/json. Some endpoints use multipart/form-data for file uploads, and some support application/xml for specific use cases. Check the documentation for your target endpoint to confirm which content types it supports.
Request Content-Type
Any request that includes a message body, typically POST and PUT requests, must include a Content-Type header that matches the format of the data you are sending.
For example, you can format an SMS message in either JSON or XML, but you have to fill out the Content-Type header accordingly.
Set different response type
By default, the response format mirrors the request format. If you need the response in a different format, for example, when sending multipart/form-data but wanting a structured JSON response back, you can override this behaviour using the Accept header or a path extension.
The Accept header format
Set the Accept header to the format you want the response in, independently of the request format.
Response Content-Type
You can specify the desired API response content type in one of two ways: the Accept header or path extension.
Accept header
Request example:
Response example:
For Bad Request schema, see: Schema reference and error handling.
Response parsing
JSON format does not guarantee the order of name/value pairs in objects. Therefore, you should never depend on the order of properties when parsing JSON API responses. For more details, see: Backwards compatibility.
Depending on your language of choice, there is either native support for JSON / XML parsing built-in, or you might use some external library that handles it.
Path extension - legacy
If you are unable to modify the Accept header of your API call, append the request path with the extension corresponding to the content type of your choosing.
| Content type | Path extension |
|---|---|
application/json | .json |
application/xml | .xml |
The following request:
Will result in a response with the XML format.
Further reading:
Base URL
How to find and use your unique Infobip Base URL in every API request.
Schema reference and error handling
Bad Request schema and error response structure for all Infobip APIs.