Why do I get an "invalid character" error when I make a Notehub API request?

When I make an API request to Notehub, I receive the following:

"err": "malformed request",
"code": 400,
"status": "Bad Request",
"request": "/v1/projects/app:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/devices/dev:xxxxxxxxxxxxxxxx/provision",
"details": {
"body": ""
"debug": "invalid character '-' in numeric literal"

It doesn’t seem to matter what request I make, I get the same message in the debug field of the response.

Solution - Ensure Encoding is JSON

Make sure the body of the request is formatted as raw JSON.

That is use

Content-Type: application/json

in the HTTP request.

If it is sent as form-data or x-www-form-urlencoded then you will see the above error message.

Here’s an example using cURL

curl --request POST --url 'https://api.notefile.net/v1/projects/app:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/devices/dev:xxxxxxxxxxxxxxx/provision' --header 'Content-Type: application/json' --header 'x-session-token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' --data '{"product_uid":"com.email.name:projectname"}'

Here’s an example of how the body is formatted correctly in Postman.