Passing additional scope into the body of an API call

Hi friends,

I'm trying to run through a loop of uploaded images and send each one to cloudinary. Cloudinary doesn't support uploading images in bulk, so we're using the loop to do them one by one.

The query itself works great for a single image, but I can not figure out how to pass the data correctly in the loop. It should use the base64 values of the selected images in a file dropzone component. They should get sent to cloudinary in the body of the API request as the "file" key.

To my understanding, this can be passed via additionalScope, but that hasn't been working for me.



Here is the output of the query as well.

Hi @Drowe003,

I think you need to actually add the key in your JSON body file and refer to the additional scope that's been sent but currently not used.

You sould be able to refer it as a varible, i.e. {{ file }}

@MiguelOrtiz

I tried adding the file key into the API call query with a blank value, but when I run the call through the loop it tried to send "file" and the blank value rather than using the additionalScope.

Is there something I'm missing here?

Hey @Drowe003,

Have you tried adding {{ file }} instead of leaving it blank? When the JS triggers the query and sends the additional scope, you can refer to it as you would with any other variable in the system. What you are seeing in the result as additional scope is just informing you about the additional scope that was available, but it is actually not used until you indicate where to use it.

1 Like

Hey @Drowe003,

Just double checking if you were able to solve this

Hey @Drowe003! I think @MiguelOrtiz is pointing you in the right direction here.

Triggering a query with additionalScope simply exposes a key-value pair that you can then reference within the query itself. In this case, that means referencing {{ file }}. You will likely need to add a key of file to the body of your query that is set equal to {{ file }}.

I recommend checking out @victoria's post here on utilizing additionalScope if you haven't seen it before! Let us know if you run into any other issues or have additional questions.

1 Like

Thanks both, this worked!!!

Literally just had to add {{file}} into the API call. Such a simple fix, that I spent hours trying to find on my own. Feeling grateful for this forum.

@MiguelOrtiz @Darren

3 Likes