Consume Rest API (400 Bad request)

  

Hey Guys,


I was trying to integrate Mailjet Services through Rest API,

When i test that from test window. Its working and i am getting the exact response.


This is the Request Body

{
    "Messages":[
      {
        "From": {
          "Email": "support@sportsmadeez.com",
          "Name": "Sports Made Easy"
        },
        "To": [
          {
            "Email": "Kvasan@mygamesolutions.com",
            "Name": "Keerthi"
          }
        ],
        "TemplateID": 593942,
        "TemplateLanguage": true,
        "Subject": "Your official USTA Ranking Update",
        "Variables": {
    "UserName": "Andrew Spurck",
    "RankingClickhere": "https://mgsi-dev.outsystemsenterprise.com/CoreCommonItems/Ranking.aspx?Unsubscribe=false&PlayerId=164667",
    "UnsubscribeClickhere": "https://mgsi-dev.outsystemsenterprise.com/CoreCommonItems/Ranking.aspx?Unsubscribe=true&PlayerId=164667"
    }
      }
    ]
  }


And the Response Body (Success)

HTTP/1.1 200 OKContent-Type: application/json; charset=UTF-8(Show all headers)

 "Messages": 

[    {      

"Status": "success",     

 "CustomID": "",      

"To": [        

{          "Email": "Kvasan@mygamesolutions.com",          

"MessageUUID": "552f3116-47ce-4ac0-ae22-a2393bd63fec",          "MessageID": 288230376198937558,          "MessageHref": "https://api.mailjet.com/v3/REST/message/288230376198937558"        }      ],      "Cc": [],      "Bcc": []    }  ]}



But when I try to pass values through assigns in Logic, it throws me 400 BAD REQUEST


these were the steps I have done

1. added the local variable


2. Assign values for FROM 

3. Assign values for TO, since the TO is a list type, I have added a local variable of the structure(TO) and appended the values


4. Assigned the remaining values

 

5. I checked through breakpoint to verify the values were passed or not, every value was assigned correctly

When I try to step over during breakpoint scenario, it's not even responding anything

Is there anything wrong in the assign values.


I got confused because I have hardcoded the same values in test request body in REST, it was a successful response.

Does anyone have any Suggestion/Solution?


and this is the error logged in the service centre

Hi Keerthi.

Did you check mailjet documentation for the Send method?

https://dev.mailjet.com/guides/#send-api-errors

The API should be returning a Messages structure with a detailed error.

Hey Joao,

Thanks for your reply.

I actually getting the test response from API.

Please verify the first content in the post, I have added that.

Solution

Hi Keerthi,

Have you set the debug level of the REST API to "Full", so that you can see what request has actually been sent?

Solution

Hey Kilian,

Thanks for this info. Let me check with that and come back to you. : )


Thanks, Killian.

The Link helped me analyze and fix.

After changing the debug mode. It logged me an exact Error reason.

I fixed that issue. and its working as expected 

Hi Keerthi, great I could be of help. Happy coding!