POST help (Example included)

Hello, me again :slight_smile:

I’m digging in to the POST functionality as it is pretty much the next biggest step after GET :slight_smile:

I need some help understanding it though as there is a lack of knowledge on my side when it comes to these things and the examples provided didn’t help me in understanding it.

As far as I understand… a POST will allow me to send data to a URL (action url) that is “waiting” for data. (Is this a webhook?)

I need to send along 3 different pieces of data to this url:

  1. Headers

  2. Body

  3. Return type

  4. I do not understand the requirements of Headers in this regard at all. Please explain this one to me

  5. This is the “actual” data from the sheet but in a JSON format as I understand it?

  6. Return type is optional but I don’t understand when I should or should not use this.

As an example.

I want to send the data of the 3 columns and 2 rows below as a JSON.

A1 = “Hero”
A2 = “Batman”
B1 = “Name”
B2 = “Bruce Wayne”
C1 = “Enemy”
C2 = “Joker”

  1. I am using https://postb.in/ as my action url

  2. What headers do I have to send?

  3. How do I send the correct data?

  4. Do I need to have a return type?


Thanks a lot for the help.

1 Like

Hey Colin!

As you mentioned the POST function takes 4 parameters (3 mandatory and an optional one):

  • action_url: The API URI (e.g. https://postb.in/api/bin)
  • headers: Takes a JSON file and mainly used for authentication.
  • body: Takes a JSON object and is mainly the data you’re sending in the request.
  • return_type (optional):
    • The default “0” returns the response content from the server.
    • “1” returns the request status (e.g. =POST(“https://httpbin.org/post",,’{“hello”:"world”}’, 1) returns “200” indicating that the request was successfully sent. While =POST(“https://httpbin.org/wrongurl",,’{“hello”:"world”}’, 1) returns “404” indicating a bad request because of a wrong URI or missing resource.)
    • “2” returns the server response as a JSON object with the status, response headers, and content. So a combination of 0 and 1.

For example, when using Postbin:

  • When checking out their API documentation, you’ll find that the POST request to create a bin only needs the API URI without headers or body (so we can leave these required parameters empty. So if we do:

A1: =POST("https://postb.in/api/bin",,)

This will return a JSON object with the bin ID created (binId), its creation time in UNIX (now), and its expiration time UNIX (expires),

To confirm that this worked, we can PARSE the binID and use it in a get statement to get its info.

C1: binID
C2: GET Request
C3: now
C4: expires
D1: =PARSE(A1,"['binId']")
D2: =GET("https://postb.in/api/bin/"&D1)
D3: =PARSE(D2,"['now']")
D4: =PARSE(D2,"['expires']")

This will return the bin information which will look like this:

Other APIs, will require things like authentication tokens or client IDs and secrets passed as a JSON object in the headers or body of the call. To do this you can easily create the JSON object using the PAIR2JSON function and pass that to the POST.

For example, if the call required a bearer Authentication which is common in many APIs and it looks like (Authorization: Bearer xxx) where “xxx” is the API key. You can make this call as follows:

A1: Authorization
B1: Bearer xxx
A2: =PAIR2JSON(A1,B1)
B2: =POST("API URI",A2,)

Regarding webhook, we currently don’t support for it but it is definitely part of our product roadmap.

I suggest you also check out our Youtube video on Sending Data to an API for more information.
Please let me know if you have any other questions or come across any issues.

Hi Hady,

Thanks for the great response. I think I’m still missing some info in what I may be doing wrong or not understanding. I’m so close but not sure how to finish it…

I decided to test another “fake endpoint” service to practice post functions and I found hookbin to be quite a nice alternative.

As you can see at this url: https://hookbin.com/K3bZMWlRpmiyYpo7Kblk/eE7lrYKL9 I successfully sent a post request with the correct “Body”.

My final question is… How can I make a GET request to then read in the “Body” that I initially sent? I know it sounds like a dumb question as I sent that info in the first place, but I want to see how to do this nevertheless :slight_smile:

Hope it makes sense? Otherwise happy to jump on a call to explain it further sometime.

Hey Colin :wave:t3:

For Hookbin, it seems like it’s only a service to test out endpoints to make sure that requests are successfully made but there doesn’t seem to be a way to retrieve the data of the previously made requests (or at least no documentation that suggests so).

So for example, if you execute this GET request:

A1: =GET("https://hookb.in/K3bZMWlRpmiyYpo7Kblk")

Then head to your hookbin, you will find it listed as a new request with its details.

I just looked up websites that do what you were hoping to achieve and came across this one called Post Test Server. You can go there and create a “Random Toilet”. This will give you a POST URL you can use to send data. For example:

A1: =POST("http://ptsv2.com/t/qhhdl-1573550651/post",,'{"hello":"world"}')

After this, when refreshing the page, you will see the request created with an ID. You can then retrieve it by adding /d/[ID]/json.

  • ID is the ID of the POST request you made
  • json is to have the API return the response in JSON format.

So in this case:

B1: =GET("http://ptsv2.com/t/qhhdl-1573550651/d/418402647/json")

This will return the details about the POST request including the timestamp, host, etc. as well as the body we sent which is the JSON object ‘{“hello”:“world”}’

I would suggest you try out some more advanced APIs with real-life use cases like GitHub Search or the Google APIs like Google Books, for example. While these might seem more intimidating, they could actually be easier to experiment with because they have more intensive documentation.

Hope this helped. Please let me know if you have any other questions.

1 Like

Thanks Hady,

I will test that out as soon as I can!

My use case for this is that I want to see how I can get data out of Dashdash in json format that I can then use another service (Parabola) to send the data in that POST to Airtable or Google Sheets for example… :slight_smile:

1 Like

You can definitely interact with these services’ APIs directly without the need to send the data to another service first. Let me show you how you can do that.

We’ll take Airtable’s API documentation section about creating stories records as an example:

As you can see on the right part, you have:

  • The type of the request (POST)
  • The API URL (https://api.airtable.com/v0/appJDH6hu3GXa69eQ/Stories)
  • The Bearer Authorization header which I mentioned in the previous comment including your API key (which you can retrieve from your Airtable account)
  • Content-Type is JSON. This you don’t have to add since we currently only send and receive JSON in dashdash.
  • “data” which is the body of the request containing the records, fields, etc.

Setting this up in dashdash will look something like this:

A1: Authorization
B1: Bearer xxx (where xxx is your API key)
A2: API URL
B2: https://api.airtable.com/v0/appJDH6hu3GXa69eQ/Stories
A3: Headers
B3: =PAIR2JSON(A1,B1)
A4: Body
B4: (I copy and pasted the data part as you can see in the screenshot. You can make this more dynamic of course using cell references or PAIR2JSON and RANGE2JSON. We currently don't have a function that creates arrays but we can do this manually for now. I'll make sure to pass this to the team as feedback though to make this process easier.)
D1: POST
E1: =POST(B2,B3,B4)

Now what we did above is:

  • Add the API URL in B2
  • Create the authorization header out of A1 and B1 using PAIR2JSON in B3
  • Add the body to B4
  • Make the POST request in E1 consisting of the API URL, header, and body (B2, B3, and B4)

This will create the record and return this response as mentioned in the documentation.

You can follow the same method to create epics records, sprints records, etc. and more or less do the same thing with Google Sheets, except that they use access tokens instead of API keys.

Please let me know if you have any questions.

1 Like

So cool! Thanks again Hady!

I got it working (Of course entirely because of your steps).

However, there are a bit too many complications in getting the formatting of the body right in an automated fashion without intervening manually.

Also, I’m a bit overwhelmed with the next steps after having created new records to then update them. I feel as though my sheet will become a nightmare and mass corruption of data would occur :stuck_out_tongue:

I think I may be better off waiting for the Airtable integration for Dashdash :smiley: or even better, a Zapier integration where I can do this in a more visual manner.