@Dino@Google @Anil Sagar @ Google @Siddharth Barahalikar@RavindraSingh
I have opened a subscription in mailjet for sending mail. The curl command for sending mail in postman i am able to implement successfully. But I am struggling to do the same in apigee.
In service callout it is giving me error not authorised.
I am attaching the curl command and my service call out policy..
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ServiceCallout name="SC-2"> <DisplayName>SC-2</DisplayName> <Request variable="quota.alert.mail.request" clearPayload="false"> <Set> <Headers> <Header name="Authorization">Basic:ZThiZmViNzRkNjM4Y2QzM2Y5MDUwNTc1ZDQyOTk3YzY6NDIwMjI1NTMwNTFhZTA2M2NhOWE0ZjYyZTVkMWRhYmY=</Header> </Headers> <Payload contentType="application/json" variablePrefix="$" variableSuffix="#"><![CDATA[{ "Messages": "From: vinod2006@gmail.com\nTo: vinod2006@gmail.com#\nSubject:Your email flight plan #\n\nDear passenger 1, welcome to Mailjet! May the delivery force be with you", "from_email": "vinod2006@gmail.com", "from_name": "Mailjet Pilot". }]]></Payload> <Headers> <Header name="content-type">application/json</Header> </Headers> <Verb>POST</Verb> </Set> </Request> <Response>quota.alert.mail.response</Response> <HTTPTargetConnection> <Properties> <Property name="success.codes">2xx</Property> </Properties> <URL>https://api.mailjet.com/v3.1/send</URL> </HTTPTargetConnection> </ServiceCallout>
# This call sends a message to one recipient. 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!" } ] }'
What is the error I am doing? If it is working in postman it should work in apigee sc.I am passing API_Key public and API_Key_private as base 64 encoded hardcoded as a Authorization header basic.
Please help me...
For not authorised error,
Replace semi-colon with white space from your Authorization header after Basic
<Headername="Authorization">Basic:ZThiZmViNzRkNjM4Y2QzM2Y5MDUwNTc1ZDQyOTk3YzY6NDIwMjI1NTMwNTFhZTA2M2NhOWE0ZjYyZTVkMWRhYmY=</Header>
to
<Headername="Authorization">Basic ZThiZmViNzRkNjM4Y2QzM2Y5MDUwNTc1ZDQyOTk3YzY6NDIwMjI1NTMwNTFhZTA2M2NhOWE0ZjYyZTVkMWRhYmY=</Header>
User | Count |
---|---|
7 | |
2 | |
2 | |
1 | |
1 |