Good morning Community
I am building a flow that needs to send a CSV file to an endpoint, I have managed to built the request meeting all the requirements from the vendor, however, when the request is sent then fails. Looking at the raw data that gets sent to the API in the POST request, I noticed that every part of the body that contains double quotes, get replaced with /"value"/, and this is the cause of the failure. This API is very sensitive.
Is there any way I can change this so the double quotes are left intact?, please see below the screenshot of the flow and the raw data that gets generated:
The body I am sending is this:
--fileboundary
Content-Disposition: form-data; name="module"
InternalTest
--fileboundary
Content-Disposition: form-data; name="import_template_id";
XXXXX
--fileboundary
Content-Disposition: form-data; name="payload"; filename="API_data_Test.csv"
This is the body being sent to the API, I highlighted in red what needs to be kept in only double quotes:
"body":" --fileboundary\r\nContent-Disposition: form-data; name=\"module\"\r\n\r\nInternalTest\r\n--fileboundary\r\nContent-Disposition: form-data; name=\"import_template_id\";\r\n\r\nXXXXXXXX\r\n--fileboundary\r\nContent-Disposition: form-data; name=\"payload\"; filename=\"API_data_Test.csv\"\r\n\
Is there any way I can keep the body as I am drafting it above?
I have managed to fix my issue, after going in loops and chasing ghosts, here is the answer to this.
Firstly, the quotes weren't an issue, the HTTP request is intelligent enough to understand the format and the scape is only how the UI displays it.
For this to work, I had to change the body of the request, first, I created and initialized a variable of type JSON, inside it I entered the body of the HTTP request, and in there I specified the CSV file or content that I want to send in my POST request, which I think was causing the issue, so now it looks like this:
Then, I just used the variable above in my HTTP request as per screenshot below:
And after this, the workflow worked successfully doing the POST request as expected.
In the end, things were much easier than I initially thought.
Thanks,
Angelica
Hi Ibendlin, thank you for your comment.
What do you mean with IRL? I am not really sure what you mean or how to check it. I am looking at the Input data that I can see in the request which is the one I attached to this post.
"body":" --fileboundary\r\nContent-Disposition: form-data; name=\"module\"\r\n\r\nInternalTest\r\n--fileboundary\r\nContent-Disposition: form-data; name=\"import_template_id\";\r\n\r\nXXXXXXXX\r\n--fileboundary\r\nContent-Disposition: form-data; name=\"payload\"; filename=\"API_data_Test.csv\"\r\n\
The server is giving me an Internal Server Error but nothing more.
Many thanks,
Angelica
Do you have access to the endpoint's logs? Wonder how the request comes through IRL. Maybe the escaping only happens in the Power Automate UI.
Thank you for your reply.
My current problem isn't the CSV data but the Body structure. Power Automate takes all the values wrapped in double quotes and replace them with escape quotes when sending the request as shown above.
It is a very sensitive endpoint and I have to send the data as I've shown in the screenshot, otherwise it rejects it.
I don't think you can send a CSV as form-data. Probably needs to be sent as binary, likely base64 encoded.
WarrenBelz
146,745
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,091
Most Valuable Professional