Trying to get Netsuite JSON Data into Excel Via Restlet - excel

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"

Related

Enforce s3 content type on presigned urls

i am using createPresignedPost to let users upload media to my servers, and when it is uploaded s3 dispatches event to my processor lambda, but problem is that i can not validate content-type of the file. if i do not provide
['starts-with', '$Content-Type', `image/`]
to my createPresignedPost function, system automatically assigns binary/octet-stream content-type to object, which is a problem since i can not match it against my allowed content types (say jpg png and jpeg).
but if i add the condition user can manually send allowed content-type in headers while submitting file with different content-type, say they wrote Content-Type: image/png but actually sent executable file, which i can not validate even in processor lambda because, when i do getObject or headObject command on s3 for the file, it returns the content-type that was submitted in the form earlier (image/png) even though actual content-type is different.
I am pretty sure there has to be some kind of solution for this to actually know what the file type is without relying on user to give you valid information.
Is there something i am not seeing?
I had the same problem that you're trying to solve.
The issue is there is no relation between the content of the file and its content-type metadata.
What is important to understand, is that the content-type header is part of the HTTP standard.
It was designed to allow the server to offer information about the content type to the client.
The S3 implementation uses the object metadata to send this information when a client is requesting the object.
In a non-S3 implementation, the server has full control of the content.
In that situation, it evaluates the content and sends the type of information according to its logic.
S3 does not have this feature.
It accepts any type of content and any value in the object content-type metadata.
And when someone asks for that contact, it will receive the content-type informed originally.
To solve the issue, you'll need to receive the content, validate it, associate the correct type and upload it directly to S3.
As you mentioned in the comments, resigned URLs will not help you with that.

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

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?

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.

Having trouble performing a GET request

Im going through the documentation for using Fusion Table's API and I am having trouble executing HTTP Requests.
For example, I copy and pasted this request
GET https://www.googleapis.com/fusiontables/v2/tables/1e7y6mtqv891111111111_aaaaaaaaa_CvWhg9gc
into my URL bar. What I want is to see the table with
table ID = "1e7y6mtqv891111111111_aaaaaaaaa_CvWhg9gc"
Instead, google does a search on the above code.
Any thoughts?
Thanks in advance
You cannot just copy paste that with "GET" in your address bar.
If you would like to just see the result of the GET operation you can paste
https://www.googleapis.com/fusiontables/v2/tables/1e7y6mtqv891111111111_aaaaaaaaa_CvWhg9gc
to your URL bar as your browser will do the "GET" here.
For making POST request however you may need to use some extension or tool like POSTMAN but for a simple "GET" request this will do.
I would request you to read up on HTTP GET/POST operations.
http://www.w3schools.com/tags/ref_httpmethods.asp

Resources