Help with setting up API for a non-coder

Hi Bubbler,

I have an API that I like to connect to Bubble. It’s a JSON Service. The link to the instruction is here:

https://abr.business.gov.au/json/

Is it possible to set this up in Bubble? and if it is please point me in the right direction.

Thank you.

Hi, it will be something like this then click Initialize Call button to initialize it. Sometimes it’s easier to get it set up in Postman first.

1 Like

Awesome! thanks for your help

Hi

Thanks for you help before. But need a bit more help if you don’t mind.

So this is what I got from Postman:

.

The values of what I need are in the “callback” parameters.

This is what I have in the API Connector.

When I initiate the call in Bubble, I get an error: " There was an issue setting up your call.

The API call returns a non-object and you picked JSON. Please check."

Are you able to see what I am missing here?

Thanks again

Hi,
Click ‘Manually enter API response’.
In Postman, Go to the body tab in the response and change ‘text’ to ‘JSON’ in the dropdown.
Select Command/Ctrl A and Copy to select all the response text in the body.
Paste it into the text field then remove the word ‘callback(’ and the closing bracket ‘)’.
Hit the Save button then assign fields as you normally would.

Jess

PS. Set up your call like this using the brackets.

Thanks Jess,

I think I am getting closer but still doesn’t work.

I think the API is correctly setup now (please see below)
However, when I test it out with a call I am getting an error:
Error parsing data from Apiconnector2:

callback({“Abn”:“”,“AbnStatus”:“”,“Acn”:“”,“AddressDate”:null,“AddressPostcode”:“”,“AddressState”:“”,“BusinessName”:,“EntityName”:“”,“EntityTypeCode”:“”,“EntityTypeName”:“”,“Gst”:null,“Message”:“Search text is not a valid ABN or ACN”})

The value is definitely correct but it’s saying the ACN is not valid.

I have the input formatted as text.
thanks again for your help


Before testing again, just check your request as I see you have missed out the ‘=’ before the callback [] and guid [].

And after doing that, initiate the call again.

ohh sorry Jess,

I did noticed that and fixed it already but still no luck. Same error.

I tried private key in header and in URL neither work.
I tried datatype as text and the correct data came through when I initialised.

I can have a look later tonight 10pmish. I’m on Sydney time.

Did you get this far and filled all your fields in?

Yes I did got that far.
Save and it seems to be ok, as there were no error at the API stage.

You might need Bubble support. I know that the header field probably needs Content-Type Application/jsonp as the API callback response is jsonp not json but that doesn’t work for this API. I also tried Content-Type text/javascript; charset=utf-8 as well as nosniff for the xcontent type options (see postman for all the other response headers)

The data comes across fine as JSON - if you had selected text, the entire API call would be in the one response.

Be interested in what they say when they get back to you. Hopefully it’s something simple.

Thanks for your help so far.
I’ll update when I hear back from support.

Hi Jess,

I’ve been playing around with it and not sure if my observation is correct or not but it appears that the service doesn’t like https://abr.business.gov.au/json/AcnDetails.aspx?acn=[]&guid=[]&callback=callback. It only works with https://abr.business.gov.au/json/AcnDetails.aspx?

I was able to get it to return the correct result, but now come into another error. Bubbles can’t parse the data.

You are still using text though, when it is json (well jsonp). Have you tried adding a Content-Type header with the value application/jsonp?

Morning Jess,

I have the data type as Json, was able to make the call with the correct data. Just bubble can’t parse it. This is what I got from support: " It appears that the JSON response provided by the API cannot be parsed. Since all APIs are different and don’t conform to one spec, it’s unclear if this API will be compatible. Since you were already able to initialize the call, you should use parameters / headers that are similar to the ones you used to initialize the call. These produced a response Bubble was able to parse."

What a pain, I guess try entering all the headers you see in Postman into the API Connector API call headers.

Aside from that, look into Zapier, specifically their webhooks and you might be able to middle man it eg. Your app sends a GET url to Zapier with ‘ABN url + your customer’s input field’, parses it and sends it back to your app. Don’t know if this would work, worth a try if you really need the ABN service?

See https://zapier.com/page/webhooks

Actually re-reading that I think they mean try the headers in the Backend API action in the key/value fields.