How to send a post request to a specific URI from PowerApps? - http

I am looking for a way to send a post request to a specific URI from PowerApps.
Basically I have a small audio file (webm) captured from the microphone and it's encoded using Base64. Now I have to send it to a server via post request and the encoded data should be put in the body of the request, since it is too big (for Nginx) to be put in the URL itself (?data=).
Can I achieve it in PowerApps?
Binary to encoded text (in PowerApps):
Set(BinaryAudioData_2, Substitute(JSON(Mic2.Audio,JSONFormat.IncludeBinaryData),"""",""));
Set(AudioFile, Mic2.Audio); Collect(Collection3, AudioFile);

You can trigger a Power Automate Flow from PowerApps, then Flow can target the specific URI. Read more

Related

Example of HTTP body for URL Encoded HTTP Request from Twilio Studio

I am trying to POST with URL encoded data. Based on the web server logs, I am not actually sending any data from Twilio (request size is always 131 bytes, no matter what I type in the Studio widget box).
What does a working form body look like? Do I need to encode it myself? How do I escape an "=" that is not part of the key-value structure?
When making an HTTP request with the widget, when it is set to make Form URL encoded requests you can set the HTTP parameter keys and values which will automatically encode the values. There are known as URL parameter as the encoding is Form URL encoding. The parameters are encoded as if they were in a URL, but they are sent as the POST body.

Can I have a body and a file in the Form-Data of a http request

I'm working in a Go Lang REST API repo.
I'm wanting to build an endpoint that will take in a file (as part of the form-data, so I suppose I'll use request.FormFile('my-file-key')). This endpoint should also take in a body of a JSON model (which i suppose would be decoded with something like this:
var myData model.MyModel
json.NewDecoder(request.Body).Decode(&myData)
But I'm running into a lot of issues. Is it even possible to send both a body and a file in the form-data with a http request?
If I try to send both I get errors from FormFile saying that it can't find the file of the key name (but if I send the exact same request without a body, this error doesn't happen). I guessing it's having trouble decoding the request.
What you need is a multipart request. One part can be JSON data, and the other part the file data.
If you're using a Go client to prepare the request, you need to use the mime/multipart package to create a Writer, then use CreatePart to create the JSON part, then the file part, and submit the request to the server.
On the decoding side: since the body is JSON you cannot parse it as a form. You have to use a multipart.Reader to read from the body after you parse the headers. Again, from that reader you get a Part, and read the data from that part. You'll get two parts, one for the JSON data and one for the file data.

How can I find URL in HTTP response

I am trying to create an HTTP parser, and I am interested to know how can I retrieve the URL from HTTP response message text. Does every response contain the URL of the page? Do I need to look at some fields in the header for that or just look at the packet's body? Do I need to save information from previous packets (such as location message)?
Requests have URLs, responses are data packets sent back to the client. But if you make an HTTP request, the immediate response will come from the same URL.

Does REST send its payload in the URL of the request? What about SOAP?

Do SOAP and REST put their respective payloads as a URL? For example:
http://localhost/action/?var=datadatadata
I know SOAP uses XML and sometimes runs on a different port on the server, but do you still submit data like the example above or do you send it as one big XML encapsulated packet to that port?
It depends on your HTTP method. GET method will put everything into URL while POST method only put path information in URL and the rest of them are streamed into the HTTP request body.
SOAP should also rely on HTTP protocol and hence should follow the same rule. Check out http://www.w3.org/TR/soap12-part0/#L10309

nginx resumable upload with upload_module and multipart/form

I currently upload to a webservice on an nginx server using the upload module (http://www.grid.net.ru/nginx/upload.en.html) from a custom desktop application doing a simple multipart-form POST that sends a file in one part and a base64 encoded XML with the file's metadata in another part.
The server receives this POST, passes it to my webservice which reads the metadata, processes the file and all is good.
What I want to do now is use the upload module's upload_resumable directive to do the POST in several chunks to minimize disconnection chances and allow resume. I can currently do this following the protocol described here: http://www.grid.net.ru/nginx/resumable_uploads.en.html
One sends byte ranges of the file along with some headers to identify the chunk and the session in several posts and once all the parts have been uploaded, nginx will compose the final POST containing the file name and path and pass it to your upload_pass location (which in my case CGIs to a django app).
However, I am not clear on how one would send a multipart post with this method since the protocol indicates that the body of the POST must be the bytes indicated in the byte range. I need the final post to also contain the XML I wrote about above.
I can think of sending the XML as the first bytes of the body and a header that indicates how many bytes belong to it but that would mean extra handling of the final file to remove that header and the final files are potentially in the GB size range.
Any other ideas?
Since the protocol supported by nginx specifically states that the post should not be multipart I ended up sending the file in the body, and the rest of the parameters encoded in the URL. Not the prettiest URLs but it works.

Resources