I’m finding that shared parameters simply don’t get sent anywhere in POST calls no matter what I do?
(The same occurs using the API Connector plugin in an app, so, are Shared Parameters just broken all around???)
I’m finding that shared parameters simply don’t get sent anywhere in POST calls no matter what I do?
(The same occurs using the API Connector plugin in an app, so, are Shared Parameters just broken all around???)
Hey @s.landers
Might be worth doing a bug report. I personally have never gotten shared parameters to work either, so I just put them in each time separately. It would be nice if this would get fixed. I just didn’t have the energy to do a bug report.
Hope that helps a bit.
Have done - the more of us that report it, the faster a fix is likely to be
Bubble’s response:
When shared parameters are added to an API and the call type is GET, those shared parameters will automatically add extra query string parameters to the URL of the API call.
As an example:
• For the following API call,
the URL for the Get Song API call will be: https://itunes.apple.com/search?term=beatles
• But when shared parameters are added,
the shared parameters will automatically add to the extra query strings to the URL when the call is reinitialized: https://itunes.apple.com/search?term=beatles&country=US&limit=10You will not need to further reference the shared parameter when initializing an API call as they will be automatically added to the URL.
However, Shared parameters only add to “Existing Parameters” if at least one is defined in the API call. The following API call will return 0 results because “Get Song” does not contain any parameters:
The same applies to POST calls, where Shared parameters only add to “Existing Parameters” if at least one is defined in the API call.
For example, take this POST call with only shared parameters and no individual existing parameters:
Checking our webhook, we can see that the shared parameter is not sent
However, once we add an existing parameter to the call like so,
We can see both the shared parameter and the existing parameter sent to our webhook:
I understand how this is not represented in our documentation so thank you for flagging this so we can work to improve! Let us know if you have further questions. Thank you.
I have sent back a reply with screenshots showing that this is not how it is behaving for users
Update again: getting pretty quick responses - so far we’ve narrowed it down that it only seems to be occurring if body type is Form-Data
This just in from Bubble:
Thank you for the prompt response. I appreciate you confirming this on your end as well - this is actually working as expected.
This is something we are looking to improve in the long term, but since there are currently undocumented corner cases, this is not something we will be able to act on right away.
With that in mind, here are the hidden rules for how the Shared Parameters are added to multiple calls inside an API:
- Shared parameters only add to existing “Parameters” on individual calls if at least one is defined, and only if ‘Body Type’ in the dropdown isn’t ‘form-data’. This is why both “Raw” and “JSON” for body-type are working for your shared parameters.
“Parameters” means a lot of different things, depending on context:
- For GET and DELETE calls it means key-value pairs that will be appended to the URL as QueryString parameters. It is equivalent to appending ?key1=[value1]… in the url, key-value pairs defined in the Parameters will be appended to the URL.
- For POST, PUT and PATCH calls that specify body type as ‘form-data’, parameters means the sequence of parameters that constitute the body of the request.
- For POST, PUT and PATCH calls that specify body type as JSON, parameters means a sequence of key-value pairs that will be stitched together into a single flat JSON object like {“key1”:“value1”}. NB, this overwrites anything set in the freeform JSON object that can also be entered below in the call definition
Now for shared parameters:
- If call type is GET or DELETE → “Parameters” will map into querystring Params, so shared parameters may add extra querystring params if there already is one key-value pair defined in the Parameters (in addition to any [square_bracket] template params in the url which won’t count as preexisting parameters)
- If call type is POST, PUT or PATCH (and body-type is JSON)-> “Parameters” will map to a shallow JSON object. there also already needs to be at least one key-value pair defined there, and the shared parameters will be added to the JSON.
Any other combination of parameters will result in the Shared parameters not being added to a given call.
Hi, sorry to bring up an old thread, but this is the only comprehensive resource I could find on shared parameters. I was also going to contact Bubble support on this point but it looks like there’s quite a comprehensive description here, so I may not need to do that.
After reading through this, it seems to be that shared parameters, in summary, are only activated if it is defined in the body type. Doesn’t this defeat the whole point of shared parameters - I thought the idea was that call API calls would have the shared parameters in each call regardless whether they would be defined lower down.
Have you come across any updates using the shared parameters with the Form Data option since posting this - and perhaps any updates of the API working without defining it in the main API body?