Unexpected token
-
Hi,
Thanks for a amazing product. However I have run in to a issue. I follow this guide: https://formidableforms.com/knowledgebase/formidable-api/how-to-add-contacts-in-sendinblue/
The thing is my form cant send anything to my sendinblue lists. I checked the log and it states:
Response
{
“headers”:
{},
“body”: ”
{
“message”: “Unexpected token } in JSON at position 226″}”, “response”:
{
“code”:400,”message”: “Bad Request”
},
“cookies”:[],”filename”:null,”http_response”:
{
“data”:null,”headers”:null,”status”:null}}
frm_entry14
frm_action14459
frm_code400
frm_messageUnexpected token } in JSON at position 226
frm_urlhttps://api.sendinblue.com/v3/contacts/
frm_request{
“updateEnabled”: true, “email”: “[email protected]”, “emailBlacklisted”: false, “smsBlacklisted”: false,
“attributes”: {
“FIRSTNAME”: “Oskar”, “LASTNAME”: “Hanborg”,
},
“listIds”: [4,5]
}
frm_headersContent-type: application/json; charset=UTF-8 api-key: API key
1) I think I found the problem. Maybe. But I have no clue how to fix it. So I read here: https://bobbyhadz.com/blog/javascript-unexpected-token-u-in-json-at-position-0
It says there that it is a undefined value. If we look at the code in your guide it says “$arg_array[‘headers’][‘api-key’]” But we are only defining the api-key and not the headers – if I understand this (I am a non-coder, just learning by googleing this). Can that be fixed by any chance?Code that I put in my function file for reference (I change where I need to change):
add_filter( 'frm_api_request_args', 'my_custom_frm_api_request_header', 10, 2 ); function my_custom_frm_api_request_header( $arg_array, $args ) { if ( $args['url'] == 'https://api.sendinblue.com/v3/contacts/' ) { // the full url where the request is being sent $arg_array['headers']['api-key'] = 'Your-API-Key-Here'; //Replace Your-API-Key-Here with your Sendinblue API key } return $arg_array; }
2) In the log it states “Unexpected token } in JSON at position 226”. If I look in my function file at line 226 then its at that bracket in the code above = the one after/under “your-api-key-here”. Any idea if this could have anything to do with this also?
Best regards,
Flamuren
- The topic ‘Unexpected token’ is closed to new replies.