Get response body from post request with skuid in model

  • 1
  • Problem
  • Updated 12 months ago
  • Solved
Hi,
I'm trying to do a post request with skuid to an external api. Everything works fine in the post request (the payload is send and it arrives on the other endpoint) but I also need to retrieve the response from the post and cast it to a my skuid model ( the response is an array)...here is my configuration

I can't understand where I can fill the type of the response of my post method (casted to my skuid model)...
I also try to debug in dev tools and I get this error (I don't know if It is related with this problem)


[{"statusCode":500,"type":"exception","ref":false,"action":"Unknown","method":"Unknown","message":"Content type 'null' not supported for Visualforce remoting request. Expected 'application/json'.","where":"","data":"","vfTx":true,"vfDbg":true}]
Photo of Andrea

Andrea

  • 460 Points 250 badge 2x thumb

Posted 12 months ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Andrea,

A couple questions to start off:

1. Is the shape of the response body from the POST request significantly different from the shape of the data that you are sending in the POST request? If the request / response shapes (i.e. the fields sent / received) are significantly different, it might make more sense to have separate Models, one for making the POST, and one for querying for the response. Which brings me to the next question:

2. Can you access the result of the POST via a separate query, e.g. a GET request to a different endpoint? If so, what you might want to do is to have one Model for inserting new data, and another Model for querying --- and then setup a Model Action on the Model that does the "insert" to re-query the "query" model whenever the insert Model is saved.

If it ends up making more sense to stick with the single-Model approach, you can define the fields that are returned from the POST response simply by manually adding additional fields into the Model --- just click "Add Field" and specify the names of the fields that you would like to interact with. 

Regarding the error message you're getting --- I've seen this in the past but I don't recall ever figuring out what the cause was. Here's a few questions: 
(1) How are you authenticating? Are you using an auth provider, e.g. an OAuth 2 provider?
(2) What is the expected content type of the response? Is the array coming back as JSON?