I am trying to understand this API configuration and figure out what I am doing wrong. What is a ‘JSON Dictionary’ and can one be set up inside of the API plugin in Bubble?
The value of “customer_properties” needs to be the JSON dictionary:
If you’re retrieving an order’s data, change “Use as Action” to “Use as Data” - you’ll still be able to leverage the call in workflows with “Get data from external API” but this allows you to retrieve data whereas action is more for creating/modifying. e.g. Getting order details vs Creating an order.
I just took a quick look at the documentation, and you may need to send these in the parameters. I’ll be able to help out later today if someone else doesn’t jump in.
I got a hold of support who advised that they indeed do need to be paramaters, but it still doesn’t seem to want to work.
“If your plugin is not able to encode it’s requests to base64 and JSON, then you will have to use a different tool; or a custom script, leveraging our API libraries if you like (listed in the top right of the API doc).”
All of the things you have written in your screenshot should be parameters, not headers. Additionally, the request must be base64 encoded, as per the API doc page you attached a screenshot of:
“Requests are made with a GET request to the specified endpoint with a single parameter, data, which is a base64 and JSON encoded string.” Track & Identify Endpoints: Overview
If your plugin is not able to encode it’s requests to base64 and JSON, then you will have to use a different tool; or a custom script, leveraging our API libraries if you like (listed in the top right of the API doc).
So there is a single parameter “data” that is a set of base64 encoded JSON.
You should be able to test it out in POSTMAN by running the JSON through an online encoder (see above), then calling the API with a ?data=xxxxxx parameter where xxxx is the result of that encode.
Doing it in bubble is going to be interesting, however…
You should be able to build some JSON in a text input field, with dynamic fields in it.
Then push that field through an API that encodes in Base64 if you can find one. Or you could build one yourself using webtask.io (or Amazon Lambda etc) as there are loads of node.js modules that do this.
The issues isn’t doing base64 (most browsers do this natively anyway and it is available in most languages) it is finding a web service to do it reliably.
I will have a look later today to see if it is possible to do in a couple of lines and create a webtask. It tends to either work or it doesn’t and my javascript skills are not able to do anything more than call node.js modules.
If you’re doing this, i.e. if the timing is appropriate to use client functionality, may as well use the browser’s native javascript function: btoa("hello there");
results in "aGVsbG8gdGhlcmU="
I am interested in how you take some dynamic bubble data, run it through that browser function, and then make it available to send to the API via the Connector.
Additionally assuming that all the data being processed by the browser is allowed to be seen by the user … gets tricky if using private keys.
Brief outline of how it could work …
Bubble to javascript: HTML element, pass the data into function parameters with dynamic data.
Javascript to Bubble: javascript sets the value in an Input Text element, and flags it as changed. Bubble workflow event triggers on the change, and the Input’s value is available.
https://wt-nigel_godfrey-gmail_com-0.run.webtask.io/base64btoa?qtext=‘code this into base 64’
However getting it back into Bubble isn’t as easy, as it gets picked up as an array if you select JSON and if you select Text you get the double quotes front and back.
So … it is like those “funny” tests that teachers set that have 1. Read all the steps 2. Draw an elephant, 3. Make a noise like a motorboat … 25. If you have read this far sit quietly.
Thought I would add to this thread to help out anyone else looking.
Here is the editor and response from support.
Hi Justin
There are a few different ways.
One you can use our cli (https://webtask.io/docs/wt-cli), wt edit will open the editor. You can read about it in the linked page.
You can also use the make url, https://webtask.io/make will bring you into the editor to create a new task. This is not currently listed anywhere. We are doing an overhaul of our docs and it will be there.