REST API debugging

  • 2
  • Question
  • Updated 3 years ago
  • Answered
Is there any way I can actually see the JSON that gets sent for my POST or GET requests?

Thanks!
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 3 years ago

  • 2
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Yes, from Chrome, go to the Console, then go to the "Network" tab, and limit to "XHR". Then take whatever action causes your REST API request to be made. (If the request happens on page load, you will need to reload your page with the Console still open to see the requests that occur on page load).

The requests will look like this:


Click on "apexremote". This will bring up a panel where you need to scroll down to the very bottom and then click on "data":





Then copy the string value of the first item in the data array (If multiple Models are being saved / queried in close proximity, there may be multiple entries in this data array), and paste it into a text editor or JSON pretty printer (e.g. http://jsonprettyprint.com/ ), remembering to remove the leading and trailing spacesso that you get a nicer JSON representation of the request, e.g.

Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
awesome. Thanks, Zach!
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
Thanks for the great question & answer! This is now documented for posterity (well, documented in another place as well: http://help.skuidify.com/m/models-conditions-filters/l/455021-troubleshooting-and-debugging-for-external-data-sources).
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Nice work, Anna.

Just a quick note, you may want to update step 3 to include the fact that we need to be on the Headers tab when you click apexremote. I believe chrome defaults to your last tab, and I was on the Results tab at first, which caused a moment of confusion.

So, Step 3 should be:
  1. apexremote
  2. Headers
  3. Request Payload
  4. Data
(Edited)
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
Thanks! Implemented. Your word is my command.