Data API Bulk POST bug

Upon reading more about the API connector, i stumbled upon the Bulk create new things API call and have managed to turn a text document into database entries when initialising in the API connector. This method will work and all i need to do is tweak a JS output to be in the format.

Since then, it seems through that when i pass the text document via a workflow into the dynamic body of the api, nothing seems to happen. But when adding the text document directly into the body in the api connector, it works.

Screen Shot 2021-03-06 at 1.35.28 pm

1 Like

Try adding a parameter on the body, you need to mark it LONG. It’s been ages since I did it but the Json parameters are expecting single lines of text, no carriage returns, unless they’re marked as long.

It might not be exactly this but it’s something like it

1 Like

I think you need to “join with” new line. Bubble expect a plain text (you correctly set the header) with a new line for each item. But each line itself shouldn’t have any new line in it).

1 Like

I tried your solution but that didn’t seem to work.
I added the following to the value which i think is the correct format as per the documentation.

{"manager":"1609385574294x307332265553619260","league":"1615206304399x586414292095729700"}
{"manager":"1609501138963x741344965601853400","league":"1615206304399x586414292095729700"}

How do you propose I use “join with” ?

Sorry. You are using format as text, so you just need to put the delimiter

I’ have already added the delimiter as enter which does change the output in the original post. Have you got any other suggestions on what i could use in the delimiter?

I have also tried using an JS output in documented format but have not had any luck as well.

Which error message do you get?
Also, did you try to send to requestbin the same request and inspect the output
or send the result of your format as text in insomnia or postman to text the same request to Bubble

If i add directly into the value field i get a parsing error.

If i add directly into the body, its successful

I haven’t tried sending via postman.

Here is the response when using postman.
when sending a newline-seperated list of JSON objects via the parameter, how is this meant to be formatted so that the API reads correctly? any ideas?

Sending RAW works

1 Like

I’ve tested sending the payload in a requestbin and if you put it manually into the parameter, it won’t work. This will remove the new line exactly the same way if you parse it in browser url. And the same thing happen when you set it in parameter from an action.

I think you might need to send a support ticket to Bubble about this issue (personnally, I think it’s on Bubble API Bulk endpoint they should make change to use an array of object instead of a newline with plain/text) (and they should also return an array in json).

Maybe someone else will come with a solution but all my test doesn’t work (using state for example). I didn’t test store the value into DB and use it from DB too.

1 Like

I didn’t test to do it directly to Bubble server. Only in requestbin. If Bubble parse \n to be anew line, maybe it can work. So you can test using \n as delimiter

1 Like

This was something i tested earlier on when playing around with the delimiter. doesn’t seem to work either.
{"manager":"1609385574294x307332265553619260","league":"1615251305372x163979666629066750"}\n{"manager":"1609501138963x741344965601853400","league":"1615251305372x163979666629066750"}

I will lodge a ticket with Bubble and see what happens

1 Like

You can also try %20
But this is for HTML, and you submit plain text. So I don’t think it work too :stuck_out_tongue:

Bubble have deployed a fix to this issue!

Bubble have added a way to pass a free-form into the API Connector. You should now be able to use an API Connector to call to the /bulk data endpoint and create things. Also, new-line-delimited JSON objects with the proper mime-type, should now work.

Note

  • In order to use the new “raw” body feature, you should make sure that you set up the api connector to use the body type RAW, instead of JSON.
  • Once you set the body format to RAW, you will need to template in the body a bit differently, use example instead of (because raw body is often used as an XML body, and <> would be a poor delimiter in that context.


Screen Shot 2021-06-04 at 8.47.56 am

1 Like

You should set the Data type to JSON instead of Text

@Jici How it has been configured in the screenshots is how the Bubble engineers instructed me to. This has been tested and is fully functional :slight_smile:
I was able to pass a text file with 48 lines from a javascript and create 48 db entries in less then a second.

I say that the body response (not the request… raw is fine) is of JSON type and you should set this instead of text. The rest is all good. But you should set the correct type for the response. Will be easier to use this way.

@Jici I have just tested changing the data type to JSON and Bubble doesn’t like it. There is a parsing error that occurs when you pass a multi line delimited text file.

Using text as the data type works perfectly

You are right. I completely forget that Bubble (strangely) return an kind of array of json, but in text format. Each line is a json itself, but the whole thing not.

1 Like