I have a working code of curl in postman Not able to convert to service call out code

My curl command is as below.. Need help in design the code for service call out.Getting 500 error..

curl -s \
  -X POST \
  --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
  https://api.mailjet.com/v3.1/send \-H 'Content-Type: application/json' \
  -d '{
    "Messages":[
      {
        "From": {
          "Email": "pilot@mailjet.com",
          "Name": "Mailjet Pilot"
        },
        "To": [
          {
            "Email": "passenger1@mailjet.com",
            "Name": "passenger 1"
          }
        ],
        "Subject": "Your email flight plan!",
        "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"
        
      }
    ]
  }'
Solved Solved
0 5 2,641
1 ACCEPTED SOLUTION

Hi @Vinod Mehta,

Here I am pasting the code of service callout which I have tested and it is working fine.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="SC-mailjet">
    <DisplayName>SC-mailjet</DisplayName>
    <Properties/>
    <Request clearPayload="true" variable="mailjetRequest">
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
        <Set>
            <Headers>
                <Header name="Content-type">application/json</Header>
                <Header name="Authorization">Basic {base64versionofuseranspassword}</Header>
            </Headers>
            <Verb>POST</Verb>
            <Payload contentType="application/json">
            {
                "Messages":[
                    {
                        "From": {
                        "Email": "pilot@mailjet.com",
                        "Name": "Mailjet Pilot"
                        },
                        "To": [
                            {
                            "Email": "passenger1@mailjet.com",
                            "Name": "passenger 1"
                            }
                        ],
                        "Subject": "Your email flight plan!",
                        "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"
                        
                    }
                ]
            }
            </Payload>
        </Set>
    </Request>
    <Response>mailjetResponse</Response>
    <HTTPTargetConnection>
        <Properties/>
        <URL>https://api.mailjet.com/v3.1/send</URL>
    </HTTPTargetConnection>
</ServiceCallout>

I would suggest some checkpoint you should check in the service callout.

- Check --user is the Authorization so in service callout you need to pass the base64 version of the username and password which you are getting. On postman you can see what is the value of base64encode of your code.

- Check if your are setting up the proper request verb. it should be POST as I have setup in the example. I would suggest copy the above code and pase it in your service callout then change <Header name="Authorization">Basic {base64versionofuseranspassword}</Header> line only. See the success in the screenshot.

8988-screen-shot-2019-08-09-at-64315-pm.png

View solution in original post

5 REPLIES 5

Hi @Vinod Mehta,

Here I am pasting the code of service callout which I have tested and it is working fine.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="SC-mailjet">
    <DisplayName>SC-mailjet</DisplayName>
    <Properties/>
    <Request clearPayload="true" variable="mailjetRequest">
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
        <Set>
            <Headers>
                <Header name="Content-type">application/json</Header>
                <Header name="Authorization">Basic {base64versionofuseranspassword}</Header>
            </Headers>
            <Verb>POST</Verb>
            <Payload contentType="application/json">
            {
                "Messages":[
                    {
                        "From": {
                        "Email": "pilot@mailjet.com",
                        "Name": "Mailjet Pilot"
                        },
                        "To": [
                            {
                            "Email": "passenger1@mailjet.com",
                            "Name": "passenger 1"
                            }
                        ],
                        "Subject": "Your email flight plan!",
                        "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!"
                        
                    }
                ]
            }
            </Payload>
        </Set>
    </Request>
    <Response>mailjetResponse</Response>
    <HTTPTargetConnection>
        <Properties/>
        <URL>https://api.mailjet.com/v3.1/send</URL>
    </HTTPTargetConnection>
</ServiceCallout>

I would suggest some checkpoint you should check in the service callout.

- Check --user is the Authorization so in service callout you need to pass the base64 version of the username and password which you are getting. On postman you can see what is the value of base64encode of your code.

- Check if your are setting up the proper request verb. it should be POST as I have setup in the example. I would suggest copy the above code and pase it in your service callout then change <Header name="Authorization">Basic {base64versionofuseranspassword}</Header> line only. See the success in the screenshot.

8988-screen-shot-2019-08-09-at-64315-pm.png

@Vinod Mehta, did this asnwer helped you?

yes it did..

Hi Ravindra,

Can you help be in getting Service Callout code for below CURL

curl --location --request POST 'https://wd2-impl-services1.workday.com/ccx/oauth2/mXXc/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic TTJKbUBZelJqTFRoaU1qSXROell3TVRneVpqUTNaVFF3Onc2a2w1Znd0OGF1N2ZqMHM1MWhyOTIycmFheWFjZzQyamh1aHJkdWYxMGl2cjNteDBicmEzZ3R6N2l5ZXM4aGcwYW1wZHpwOWZkdXB6eDFjM2gxN3JiZ2lmempwMHh3ejAyZw==' \
--header 'Cookie: WorkdayLB_SIRG=976261642.48685.0000; TS012df9cf=01da122c492925df5283530b0f93392c82aaa4205c2aad4deeadfc03d1c57e6e7f79a036243dda7068848aa9fb918ef9b574ebe9cd' \
--data-urlencode 'grant_type=refresh_token' \
--data-urlencode 'refresh_token=gez2h9uur3fgpv8kjlqhnoxrn12ahc0h5c79p96uncgintkrh21655lacv6vyymqvrmf8p34kc3zgbtlzeta'

@Pravin Ingawale - please remove (redact) sensitive info from your cURL