Forum Discussion

dMoney's avatar
dMoney
Active Member
10 months ago

Need Help Troubleshooting Connected Content Call

I'm trying to do a connected content call to the Trustpilot API so that I can get back an individualised URL for a customer to submit a trustpilot review: https://documentation-apidocumentation.trustpilot.com/invitation-api#generate-service-review-invitation-link 

This requires 2 calls, one for the Oauth token and a 2nd to call the endpoint that generates the link.

I've been able to successfully do the first call, but having issues with the 2nd, mostly because Braze isn't giving me any feedback.

Here is the call (sans sensitive IDs):

 

 

{% connected_content https://invitations-api.trustpilot.com/v1/private/business-units/xxxxx/invitation-links :method post :headers {"Content-Type": "application/x-www-form-urlencoded", "Authorization": "Bearer {{token.access_token}}" } :body name={{${first_name}}}&referenceId={{${user_id}}}&local='en-US'&email={{${email_address}}} :save result %}

{{result.__http_status_code__}}

{{result.url}}

 

 

You can see after the connected call I'm also trying to return the HTTP code and also the expected URL to help with troubleshooting.

However, I'm not getting anything returned in those blocks. In addition, the Dev console doesn't seem to be much help because one minute I'll get some feedback (such as a 401 error) in it. The next minute, without changing anything, no errors will show up. And I can't get anything to show up even when I deliberatly try break the connected content call.

Any help with better ways to troubleshoot connected content calls or if you can spot any errors in my specific call would be appreciated.

 

2 Replies

  • Hey, looks like your body is not a valid JSON format / object. But the API wants one -> application/json. And you're not putting your data into a string. But the documentation says that the values of your keys should be a string. Next it should be "locale" and not "local". And last but not least, you don't handle errors. Try this one:

     

    {% capture postbody %}
    {
       "name":"{{${first_name}}}",
       "referenceId":"{{${user_id}}}",
       "locale":"en-US",
       "email":"{{${email_address}}}"
    }
    {% endcapture %}
    
    {% connected_content
    https://invitations-api.trustpilot.com/v1/private/business-units/xxxxx/invitation-links
    :method POST
    :headers {
        "Content-Type": "application/json",
        "Authorization": "Bearer xxxxx"
    }
    :body {{postbody}}
    :content_type application/json
    :save result
    %}
    
    {% if result.__http_status_code__ != 200 %}
      {% abort_message('Connected Content returned a non-200 status code') %}
    {% endif %}
    
    {{result.url}}

     

    Let me know if you have any further questions 🙂 .

    Max

  • Hello dMoney 

    I don't see any issues with the code. Just an observation of the body of the payload.

    Can you try changing the locale value to en-US instead of 'en-US'?