Forum Documentation Showcase Pricing Learn more

API gives different responses destroying data structure

#1

Hi there!

I need help! I’m using the Bing Search API. Depending on the query entered, the structure of the response changes.

E.g. if I enter “2+3” it response with a math equation.

E.g. if I enter Obama it response with a lot of Photos.

But since I am building a search for all cases, I don’t know what the final user will enter.

Problem: if I want to set up the Api with the Api connector, I can only enter one query type and therefore get only one type of response answer.

Meaning I only can’t build a front end that supports all scenarios.

I used a math equation to set it up in the connector. Then I wanted to add the other use case, so I changed to query in the Api connector to Obama. Now I can add the photo visualisation, but it is giving me errors, because there is no more math equation response.

I’d be thankful for any help!

0 Likes

#2

I think, but not sure, that you may use the manually enter API response. This will let you add differents options that the API can return. And maybe you can use filter like (if image is empty…) to display the right result you want. Also you may consider using different call according to request (maybe you can use a menu where user can choose image, math, news…) and use call according to that (responseFilter)

1 Like

#3

@Jici is correct. In order to have a single api connector call, you’ll need to manually enter all the response objects you want to support. If you are lucky, you can find an example online. If not, you have some work to do as the bing api returns many different object types, not to mention a different error response.

I usually open up postman, and start making calls to the api. Save the response you receive each time. Then compile it into a single (and valid) json response by merging everything together in their appropriate parent object – note merging, not simply appending all the responses.

Once you have the entire json ready, you use the api connector option to manually manage the response and paste it all in. It definitely works, but it will take some time to get all the possible options covered.

–Ken

2 Likes

#4

Thanks soooo much @Jici and @mebeingken! You two saved my day. I didn’t know that it was possible to edit the response. It is hidden very well, I find.

Thanks!

1 Like