Call API DATA 'USER" > JSON

Good morning,
For a few weeks I have been stuck making an API data call from a repetitive group.

I correctly configured the data and created the API on bubble as well as the installed plugin.

I would need help to configure this API in order to be able to download a .json document following this API
The JSON data I need is a list of driver input for the built-in simulation game (server access)

In my repetitive group (RP REGISTRATION), all data is accessible and comes from the ‘USER’ “CARS” and “INSCRIPTION” table and Option SET for catégorie.

Here is the structure of the Json I need with for example 2 registered drivers:

{
“entries”: [
{
“drivers”: [
{
“firstName”: “NAME1”,
“lastName”: “LAST1”,
“shortName”: “MAN”,
“driverCategory”: -1,
“playerID”: “S7656119897568888”
}
],
“raceNumber”: 7,
“forcedCarModel”: -1,
“overrideDriverInfo”: 1,
“defaultGridPosition”: -1,
“isServerAdmin”: 0
},
{
“drivers”: [
{
“firstName”: “NAME2”,
“lastName”: “LAST2”,
“shortName”: “LAM”,
“driverCategory”: -1,
“playerID”: “S76561198035968888”
}
],
“raceNumber”: 8,
“forcedCarModel”: -1,
“overrideDriverInfo”: 1,
“defaultGridPosition”: -1,
“isServerAdmin”: 0
}
],
“forceEntryList”: 1
}

If someone could help me configure the API call via the plugin and how I can download it via a button for example. Thank you in advance

You really haven’t given enough info for someone to diagnose this.

A setup of your API call, any workflows. Error messages in Bubble or your console. Etc.

You do have an error in your JSON structure:

Error: Parse error on line 1:
{“entries”: [{“driv
-^
Expecting ‘STRING’, ‘}’, got ‘undefined’

I got that from running it through a JSON validator:

I changed the JSON example to an error, (it was a comma)

I may have misspoken, I’m not asking for help on a diagnosis but how to build the configuration of the data API call to retrieve this data (document to be downloaded in .json format) from a repetitive group so that it is formatted in the same way as on my example.

Currently I’m using a repetitive scond group where each input is an HTLM component so I can copy/paste into a .json file but this is really inconvenient.


1 Like

Ok sorry, I probably misread your question.

So, I guess you could create a new API call in the API Connector and set the method to post.

Then the API endpoint has to be built to get the driver input JSON data.

Of course, if your API requires you need to put in any required headers. The header content type is application/JSON.

Then initialize the JSON:

{
“entries” ,
"forced EntryList: 1
}

Do the API Workflow on a List Action.

Run on repeating group - RP Registration

select “generate_driver_JSON” API Call

then send dynamic data for each driver to API call

{
“drivers”: [
{
“firstName”: Current cell’s USER’s first name,
“lastName”: Current cell’s USER’s last name,
“shortName”: Current cell’s USER’s short name,
“driverCategory”: Current cell’s Option Set’s category,
“playerID”: Current cell’s USER’s player ID
}
],
“raceNumber”: Current cell’s INSCRIPTION’s race number,
“forcedCarModel”: Current cell’s CAR’s model ID,
“overrideDriverInfo”: 1,
“defaultGridPosition”: -1,
“isServerAdmin”: 0
}

Make sure your button is set up right.

That’s the best I can suggest without being hands-on with what you have.

1 Like

Thank you for your help,

I understood the 2nd part for the WF but it’s been 2 hours that I’ve been trying by all means and without success to initialize the API and I get each time the error code 400, 401 or 404 by trying a lot of things. I think the ending I’m trying to enter is wrong, or I don’t understand. I added 1.1/obj/user at the end and checked user in the API settings.
I’m a bit lost, it’s very frustrating. I’m going to dig a little deeper tomorrow.

Thank you

Despite the fact that I managed to initialize the API, I believe that all of this seems to be beyond my competence.

I’m thinking of putting this feature aside for now or bringing in someone later. I think I’d need a complete step-by-step example.

Thanks anyway for helping you and if anyone has another lead I’m obviously up for it;)