Category: Question and Answers
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

How to pass string of comma separated integers as value for a JSON object key in the body of API

Issue

I am trying to pass a string of comma separated integers as the value for a JSON object key in the body of an API. However, it seems to be malfunctioning as it is converting the string value into a number and only passing the first number before the comma.

Resolution

If you're trying to pass a string of comma-separated integers as the value for a JSON object key in the body of an API, you can do so by wrapping the string value in double quotes. This will ensure that the entire string is treated as a single value, rather than being converted into separate numbers.

For example, suppose you have a JSON object with a key "numbers" that should contain a string of comma-separated integers. You can pass this value in the body of an API request as follows:

{
"numbers": "1,2,3,4,5"
}

Note that the string value is surrounded by double quotes. This ensures that the entire string is treated as a single value.

If you're still having issues with your API malfunctioning, it's possible that there's another issue at play. You may want to check your API documentation or reach out to the API provider for more assistance.