HTTP request JSON response data

(Viljami Ketola) #1

Hello,

I browsed through old questions about the same kind of problems and I found almost exactly same problem but the solution didn’t work for me.

I have an API that I should poll at the certain point. I can do this and everything goes well exept for the result I’m getting from the API. When I try it on Postman it gives me this response body

[
    {
        "result": "0"
    }
]

When I do the same request from the bot I get status:200 but no body. I checked the results from Interactions tab in flowxo, but it doesn’t recognize the response body at all. Is there some kind of limitation how API should send the response? This response is JSON and the request is done with form data (but that shouldn’t matter, right?).

I’m also trying to access the data in the next message of the bot with {{httpfetchcontact.data__0__result}}

Any idea what’s from?

(Daniel Beckett) #2

Hi @Viljami_Ketola

On Postman are there extra headers included? I believe they add some by default. You could try adding the same headers to your HTTP request in Flow XO.

(Viljami Ketola) #3

Postman gives these two headers:
headers = {
‘Cache-Control’: “no-cache”,
‘Postman-Token’: “fe898b75-8d0e-4430-8461-38a84f9e03b8”
}

(Daniel Beckett) #4

Can you share some information on how your webhook is setup? Feel free to email support@flowxo.com if you’d rather not share it on here.

(Viljami Ketola) #5

Here’s the data I’m sending with the request. Is this what you meant with webhook setup?

(Daniel Beckett) #6

Yeah, that’s what I meant. Nothing is really standing out as an issue though.

Does the service you’re sending the request to have any API documentation? It would be best to check on that side to see what’s expected in order to get the result you want.

(Viljami Ketola) #7

There’s no documentation, but I’ll throw a message to their support and ask if there’s something blocking the response atm.

(Viljami Ketola) #8

At the API’s end they couldn’t find a problem. They guessed the problem might be in flowxo request handling.

I send two parameters with request: a secret and a user_id. Both parameters are required and no additional fields are taken into account.

  1. If secret is invalid, it returns error page (XML parsing error) that has no source code if try to inspect it.
  2. If userid is invalid, it returns status: 200 and [{“result”: “0”}]
  3. if both are correct, it returns status: 200 and [{“result”: “1”}] and user object. (haven’t gotten so far though…)

Here’s the header information from the request that I sent from browser. This is from request that works (case 2).

Cache-Control: private
Content-Length: 16
Content-Type: application/json; charset=utf-8
Date: Mon, 06 Aug 2018 10:03:22 GMT
Server: Microsoft-IIS/8.5
Set-Cookie: ASP.NET_SessionId=**********; path=/; HttpOnly
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: en-GB,en;q=0.5
Connection: keep-alive
Cookie: ******************************
Host: ************.*******.fi
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0
(Daniel Beckett) #9

Hi @Viljami_Ketola

It’s difficult to say what’s going wrong here really.

The Webhooks & HTTP service is mostly just a simple tool to construct your own requests. If there’s an issue with sending then it’s likely down to either the method being used or certain header information missing from the request.

You may want to experiment with some of the other settings such as sending a RAW request with the content-type specified.

(Viljami Ketola) #10

I’ll try that, but does raw request need to be parsed before sending it because I have northern europe characters in there [öåä]?

Can I see somewhere what headers are applied when I send request from flowxo? In interactions there’s no info about that.

(Viljami Ketola) #11

Nvm, I got it working. I put parameters to the request url field too. I don’t know what was the problem but this worked.

I hope I don’t have same problems with post data.