GET Request is not working when I define Accept octet-stream output format - get

I'm trying to execute a GET Request in Postman to a specific endpoint to retrieve an octet-stream that represents an Employee Picture.
It works using POST Request type, as you can see in the following screenshot:
I know that the same service can be provided by using a GET request. I've tried this, and initially, it works when I don't add the Accept application/octet-stream in the Header of the GET Request:
But, as you can see, it did not give me the binary output (jpg image). It just retrieves the file name.
If I add the Accept octet-stream (which I'm using in the POST request shown above), I get the following error in Postman output:
Can I assume the service does not support accepting octet-stream in the GET Request? Or am I missing something in the GET Request in order to have the expected binary output as I have in the POST Request output?

Related

Serving a HTTP request response as a dialog response - Composer Framework

We are developing a chatbot to handle internal and external processes for a local authority. We are trying to display contact information for a particular service from our api endpoint. The HTTP request is successful and delivers, in part, exactly what we want but there's still some unnecessary noise we can't exclude.
We specifically just want the text out of the response ("Response").
Logically, it was thought all we need to do is drill down into ${dialog.api_response.content.Response} but that fails the HTTP request and ${x.content} returns successful but includes Tags, response and the fields within 1.
Is there something simple we've missed using composer to access what we're after or do we need to change the way our endpoint is responding 2? Unfortunately the MS documentation for FrwrkComp is lacking to say the very least.
n.b. The response is currently set up as a (syntactically) SSML response, this is just a test case using an existing resource.
Response in the Emulator
Snippet from FwrkComp
Turns out it was the first thing I tried just syntactically correct. For the case of the code given it was as simple as:
${dialog.api_response.content[0].Response}

Cannot load webpage from Postman because of javax.faces.ViewState?

I am trying to integrate a web application written by someone else with an API written by someone else. At the moment I am trying to test one of the webpages using Postman. When the webpage is loaded in a browser it works correctly. I have replicated all of the headers and body in Postman, however when I try to launch the webpage in Postman a HTTP 500 status code appears (internal server error).
I think the issue is with: javax.faces.ViewState, which is a body key/value pair. I initially do I get request to the webpage in Postman and get the viewstate:
I tried passing the value: xxxxxxxxxxxxxxxxxxxxxx;yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy in the body key/value pair, but still I get an internal server error. I have also checked that the JSESSIONID cookie is identical in the GET request and the POST request.
I have also noticed that if I access the webpage from a browser, then there is a colon instead of a semi colon in the value if that has any bearing.
Most of what I have tried so far was suggested in the answer to this question: How to programmatically send POST request to JSF page without using HTML form?
What am I doing wrong?

How to use azure logic app action to download files in browser

I originally created a logic app that would, given a JSON payload, run a stored procedure, transform the results into a CSV table and then email the CSV to a specified email account. Unfortunately requirements changed slightly and instead of emailing the csv they want it to download directly in the browser.
I am unable to get the HTTP response action to tell the browser to download the file using the Content-Disposition header. It looks like this is pulled out of the request by design. Is anyone aware of another action (perhaps a function?) that could be used in place of the HTTP response to get a web browser to download the file rather than returning it as text in the response body?
It does indeed seem to be the case that the Response action doesn't support the Content-Disposition header for some reason. Probably the easiest workround is to proxy the request through a simple HTTP-triggered Azure Function with CORS enabled (or an API on your server) that just fetches the file from the Logic App and then returns it with the Content-Disposition header attached.
NB. Don't rely on <a download="filename"> - most browsers that support the download attribute only respect it for same-origin requests.

Trying to get Netsuite JSON Data into Excel Via Restlet

I'm trying to use Excel to connect to a netsuite restlet script to pull information and populate a sheet.
I have tried to connect via "web" and entering the url and adding headers. If I try to add the content-type to be application/json, I get an error that "name":"INVALID_RETURN_DATA_FORMAT","message":"Invalid data format. You should return TEXT"
I saw that I can connect to a JSON file via Excel, or to a webservice, but it doesn't seem to return the json object. Is there something I am doing wrong? I have the authorization and content-type headers, and my url is correct for the external url of the webservice. Is there a better way to do this?
The purpose of this file is to essentially pull down records of a certain type into Excel, allow the user to edit, and then push that information back into Netsuite. The restlet is working well, now I just need to get the Excel portion working properly.
Thanks!
You need to include a Content-Type Header in your request.
Content-Type: application/json
NetSuite looks at this not only to identify the request body format, but also the encoding of the Restlet's response. (It's a bit counter-intuitive, because usually an Accept header is used to tell the server the response content type expected, especially if you are just sending a GET request that doesn't even have a body.. but that's NetSuite..)
For more details see the Help Center topic "Creating a Content-Type Header"

Post request with Wget?

I want to use wget to upload a picture to a distant server, using an authentication token, 'AUTH_1624582364932749DFHDD', to the 'test' folder.
This command doesn't work (authorization failed), and I want to make sure that it's not about syntax:
wget --post-file=nature.jpg http://ipadress:8080/v1/AUTH_test/test/ --post-data="AUTH_1624582364932749DFHDD"
Any suggestions?
Wget currently doesn't not support "multipart/form-data" data. --post-file is not for transmitting files as form attachments, it expects data with the form: key=value&otherkey=example. It is actually possible to post other formats (json) if you send the corresponding header.
--post-data and --post-file work the same way: the only difference is that --post-data allows you to specify the data in the command line, while --post-file allows you to specify the path of the file that contain the data to send.
Here's the documentation:
--post-data=string
--post-file=file
Use POST as the method for all HTTP requests and send the specified data
in the request body. --post-data sends string as data, whereas
--post-file sends the contents of file. Other than that, they work in
exactly the same way. In particular, they both expect content of the
form "key1=value1&key2=value2", with percent-encoding for special
characters; the only difference is that one expects its content as a
command-line parameter and the other accepts its content from a file. In
particular, --post-file is not for transmitting files as form
attachments: those must appear as "key=value" data (with appropriate
percent-coding) just like everything else. Wget does not currently
support "multipart/form-data" for transmitting POST data; only
"application/x-www-form-urlencoded". Only one of --post-data and
--post-file should be specified.
Regarding your authentication token, it should either be provided in the header, in the path of the url, or in the data itself. This must be indicated somewhere in the documentation of the service you use. In a POST request, as in a GET request, you must specify the data using keys and values. This way the server will be able to receive multiple information with specific names. It's similar with variables.
Hence, you can't just send a magic token to the server, you also need to specify the name of the key. If the key is "token", then it should be token=YOUR_TOKEN.
wget --post-data 'user=foo&password=bar' http://example.com/auth.php
Also, you should consider using curl if you can because it is easier to send files using it. There are many examples on the Internet for that.

Resources