Hello and apologies for the noob question. Using jQuery for API calls and I just can't seem to make a request that contains acceptable JSON data for the api. Using something like this:
var rq = $.ajax({method: "POST",
url: "https://[...].nationbuilder.com/api/v1/people?access_token=[...]",
accepts: "application/json",
contentType: "application/json",
data: JSON.stringify(
{ person: {
email: "[email protected]",
last_name: "Smith",
first_name: "Bob",
sex: "M",
signup_type: 0,
employer: "Dexter Labs",
party: "P"
} }
)
})
Return message is always "I can only talk JSON..."
Hi Jedd,
I would suggest using an online tool such as the JSON Formatter/Validator, which gave some helpful prompts to adjust the request above to the following raw JSON:
{
"person":{
"email":"[email protected]",
"last_name":"Smith",
"first_name":"Bob",
"sex":"M",
"signup_type":0,
"employer":"Dexter Labs",
"party":"P"
}
}
It may also be helpful to consult the docs for the JSON.stringify method you're using for how that is transforming the data you're sending it.
Hope this helps, and happy coding!
Showing 2 reactions
Sign in with
Certified Developer