• Resolved flamuren

    (@flamuren)


    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_entry

    14
    frm_action

    14459
    frm_code

    400
    frm_message

    Unexpected token } in JSON at position 226
    frm_url

    https://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_headers

    Content-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

    • This topic was modified 2 years, 2 months ago by flamuren.
Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter flamuren

    (@flamuren)

    Follow up. If I remove the [headers] from the code it gives me another error in the log:

    Response 	
    
    {
    "headers":
    {
    
    },
    "body": "
    {
    "message": "Key not found", "code": "unauthorized"}n", "response":
    {
    "code":401,"message": "Unauthorized"
    },
    "cookies":[],"filename":null,"http_response":
    {
    "data":null,"headers":null,"status":null}}
    frm_entry 	
    
    15
    frm_action 	
    
    14459
    frm_code 	
    
    401
    frm_message 	
    
    Key not found unauthorized
    frm_url 	
    
    https://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_headers 	
    
    Content-type: application/json; charset=UTF-8
    Plugin Support Jonathan Martínez

    (@jonathanenlared)

    Hi @flamuren

    We’ll love to help you further with this issue.

    Could you please open a ticket in our helpdesk here for Pro plugin support?
    https://formidableforms.com/new-topic/

    Thank you!

    Thread Starter flamuren

    (@flamuren)

    Hi Jonathan,

    I did but the support person was not a coder so he did not know what to do ???♂? That why I took up the mission to google and found that blog mentioned above. That seemed it could be a solution if I only knew how to edit code ??

    Plugin Support Jonathan Martínez

    (@jonathanenlared)

    Hi @flamuren

    I just checked out the ticket thread, and it looks like my colleague shared the community link with you. The Formidable community is helpful and might point you in the right direction for your custom requirement.

    Have a wonderful day!

    Best,

    Thread Starter flamuren

    (@flamuren)

    Thanks for looking in to it. Well its not a custom requirement since its a feature that should work I guess? But I will ask in the community. Hopefully someone knows about this ????.

    Thread Starter flamuren

    (@flamuren)

    I can update on the issue now. I changed the url used in the function file to this: if ( $args['url'] == 'https://api.sendinblue.com/v3/contacts' )

    This makes a new error log saying this:

    Response

    {
    “headers”:
    {

    },
    “body”: ”
    {
    “message”: “Key not found”, “code”: “unauthorized”}n”, “response”:
    {
    “code”:401,”message”: “Unauthorized”
    },
    “cookies”:[],”filename”:null,”http_response”:
    {
    “data”:null,”headers”:null,”status”:null}}
    frm_entry

    32
    frm_action

    14459
    frm_code

    401
    frm_message

    Key not found unauthorized
    frm_url

    https://api.sendinblue.com/v3/contacts/
    frm_request

    {

    “updateEnabled”: true, “email”: “[email protected]”, “emailBlacklisted”: false, “smsBlacklisted”: false,

    “attributes”: {

    “FIRSTNAME”: “Per”, “LASTNAME”: “Treborn”,

    },

    “listIds”: [4,5] }
    frm_headers

    Content-type: application/json; charset=UTF-8

    I have been searching and found that another plugin fixed this issue. Any idea if this could be done from your side also?
    https://www.ads-software.com/support/topic/difficulty-with-sendinblue/

    It seems to go beyond what I can fix my self if its the same issue as they had. Or is there anything I can try myself? ??

    Hi @flamuren looks like you made some progress, awesome.

    I’m pretty sure that error message you’re getting back indicates the request partially went through, and that your API key is invalid. Try generating/using a different API key if possible, or double check the current one.

    The steps outlined in this support post on another plugin may help further.

    Hope this helped some, glad you found a workaround in the meantime.

    Thread Starter flamuren

    (@flamuren)

    You perhaps found the problem. I have not authorized the domain as that guide they provided. I only added the domain to the list but did not tick the “I would like to use this domain name to digitally sign my emails (SPF, DKIM, DMARC)”.

    Edit: I just saw they provided a guide how to fix this. I will will follow that and see if I can manage ????

    Many thanks for your help! ??

    • This reply was modified 2 years, 2 months ago by flamuren.
    • This reply was modified 2 years, 2 months ago by flamuren.

    @flamuren Excellent glad to help!

    Those settings are usually related to DNS.
    Log into your webhost or domain provider and dig around for some kind of DNS settings.
    Here’s a general guide.
    I’m sure you’ll be able to find a bunch more too. It may be helpful to search for a guide specific to your webhost. You could try asking their support to set it up for you, some webhosts would gladly do this for you.

    Good luck

    Thread Starter flamuren

    (@flamuren)

    you are awesome – many thanks. I set up all three but not the last one. It states to not do it if I am not a developer so I leave it.

    I use one.com for hosting.

    And for step 2 “2. Set TXT (SPF) record for “arbetssokande.nu” to ” my host put up a message telling me to also add their info otherwise it would perhaps block their emails. As they linked to here to explain: https://help.one.com/hc/sv/articles/115005595945

    I wrote step 2 like this: v=spf1 include:_custspf.one.com spf.sendinblue.com mx ~all
    But the sendinblue info tells me to write: v=spf1 include:spf.sendinblue.com mx ~all

    Is this correct or should I change it?

    Also on all the steps in the form to add these txt info on one.com there is a field for “host”, but after that field one.com adds a noneditable .arbetssokande.nu (which is my host that I should add)… should I leave the field blank and let one.com add it or should it be examplehost.com.examplehost.com – as it becomes when I manually add my host name? ??

    • This reply was modified 2 years, 2 months ago by flamuren.
    Thread Starter flamuren

    (@flamuren)

    Update: I asked one.com support and I deleted the extra added host name. Also they could se something about step 2 being propagated already. No idea what it means, but something is on the go ??

    Thanks for you awesome help friendly stranger. Internet is truly fantastic! ????

    Thread Starter flamuren

    (@flamuren)

    Number 1 and 3 are green in the sendinblue dashboard now. The second one did not verify emediatly. Also I have not set up the 4th. I dont know if that would be needed?

    Thread Starter flamuren

    (@flamuren)

    Update: all three dns settings are now verified and the domain is verified also. Still the same error log. Any idea what to do next?

    Thread Starter flamuren

    (@flamuren)

    Its now resolved.

    The problem I had was that the domain was not verified in sendinblue. Also I had not removed the “,” in the raw code after removing a attribute I do not use (the sms number). Now it works ????

    To clarify, the code that says “”FIRSTNAME”: “id”, “LASTNAME”: “id”,” should be “”FIRSTNAME”: “id”, “LASTNAME”: “id””. Its just the end thats different without a “,”.

    • This reply was modified 2 years, 2 months ago by flamuren.
Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Unexpected token’ is closed to new replies.