Any reason why this endpoint could be returning randomly an empty body with status code 200? | Community
Skip to main content
Answered

Any reason why this endpoint could be returning randomly an empty body with status code 200?

  • November 24, 2021
  • 4 replies
  • 732 views

Hello,

I am using in an app this library https://www.npmjs.com/package/@typeform/embed so once the user fills the form, I get the response id and I send it to my api to get the answers and store them in my database.

So the problem is that the data is sent correctly to my api, but this endpoint /forms/:formId/responses?included_response_ids=:response_id randomly (sometimes happen and sometimes don’t) returns an empty body with status code 200 so the responses are not stored in the db and I don’t get any error so don’t know why.

Any idea?

Best answer by mathio-tf

Hello @GaroLuis 

typeform is processing responses asynchronously and it can take some time before a submitted response is available via the API endpoint. You could request the response in a while cycle like I showed in this article or you can receive responses via webhooks in real time.

Hope this help.

View original

4 replies

Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15035 replies
  • November 24, 2021

Hi @GaroLuis Happy Wednesday! Thanks for stopping by the community. Would you mind providing a little more info on how you’re calling that endpoint? That’ll help us see why it’s sending back a 200 at random times. 


  • Author
  • Explorer
  • 1 reply
  • November 25, 2021

@LizNothing special, I’m just using Guzzle:

$this->client = new Client([    'base_uri' => 'https://api.typeform.com/',    'headers' => [        'Content-Type' => 'application/json',        'Authorization' => 'Bearer ' . $token,    ],]);
$response = $this->client->get('forms/' . $formId . '/responses?included_response_ids=' . $responseId);

$content = json_decode($response->getBody()->getContents(), true, 512, \JSON_THROW_ON_ERROR);

 

It only happens when the response is just created (I can replicate it using postman) so I was thinking that maybe it’s something like the response is not fully stored when I am doing the call, but it doesn’t make much sense.


mathio-tf
Typeform
Forum|alt.badge.img+5
  • Typeform
  • 888 replies
  • Answer
  • November 25, 2021

Hello @GaroLuis 

typeform is processing responses asynchronously and it can take some time before a submitted response is available via the API endpoint. You could request the response in a while cycle like I showed in this article or you can receive responses via webhooks in real time.

Hope this help.


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15035 replies
  • November 29, 2021

Hi @GaroLuis were you able to utilize either of the methods @mathio mentioned? :grinning: