3

I'm trying to post the following raw data to mailgun using postman, My eventual intended use is to build the request into a freshdesk webhook which will POST raw JSON to a callback URL.

I've set postman to POST the following raw JSON

{
  "from":"jwills@savills.co.uk"
  "to":"jwills@savills.co.uk"
  "subject":"test"
  "text":"working?"
}

Im receiving the response:

{
  "message": "'from' parameter is missing"
}

I'd love to know how I'm formatting the code incorrectly? Thanks

Guido Leenders
  • 4,232
  • 1
  • 23
  • 43
Jwills
  • 33
  • 1
  • 4
  • 1
    This wont fix your main problem of getting mailgun to accept JSON, but your JSON string is invalid the way you wrote it above. It's missing commas that separate the properties. It should be like: { "from": "x", "to": "y", "subject":"a", "text":"b" } – chardy Jul 18 '16 at 17:11

1 Answers1

5

Looking at the following cURL example, you need to POST the data as x-www-form-urlencoded or multipart/form-data.
https://documentation.mailgun.com/user_manual.html#sending-via-api

So to make this work in Postman, ensure the following:

Authorization:
Type = Basic Auth
Username = api
Password = [your API key]

Headers:
Accept = text/json

Body/x-www-form-urlencoded:
from = jwills@savills.co.uk
to = jwills@savills.co.uk
subject = test
text = working?

Update...

To get this to work in Freshdesk you can kludge this a little in the webhook by setting a custom header to indicate x-www-form-urlencoded, then choosing the JSON encoding (so that you can write an "advanced" content string), and then writing your body content as a url-encoded query string.

This should work as long as you're not using any dynamic placeholder value that has characters needing to be escaped.

Here's a test I created that worked for me. It's hacky, but it might be enough for your purposes:

enter image description here

chardy
  • 1,233
  • 1
  • 10
  • 18
  • Thanks for the reply, I can get it to work with x-www-form-urlencoded data but the application freshdesk can't output this. I'm only using mailgun to test the API. I can't get RAW Json working with Mailgun and I can't find anything in their API documentation? Their support agent simply replied "looks like you're missing the form parameter" which was helpful.. no idea where he might have drawn that conclusion! – Jwills Jul 18 '16 at 15:32
  • Hahaha.. A little hacky but brilliant. I'm impressed thank you! – Jwills Jul 19 '16 at 19:26