I am editing in editor.swagger.io
How can I download response from API locally which is a excel file? The API being used for converting json to Excel is written in python.
My snippet -
responses:
200:
description: "JSON to Excel conversion succeeded"
content:
application/vnd.ms-excel:
schema:
type: string
format: binary
I get server response of 200 saying
😱 Could not render this component, see the console.
In console the response headers are -
cache-control: public, max-age=0
content-length: 8515
content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
expires: Tue, 10 Dec 2019 15:14:55 GMT
I want to save excel file locally.
Figured out that Content Disposition header has to be exposed in the python code for MIME types such as application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.
In python code you should have a line like this -
CORS(app,expose_headers=["Content-Disposition"])
If your MIME type is application/octet-stream then this isn't required but for other MIME types this may be required.
Related
It seems the MS REST (EWS) services are being deprecated toward the end of 2022 and moving to graph api is recommended.
All good, graph works just fine...except for the 4MB size limit on the payload!
Ok so there is this: https://learn.microsoft.com/en-us/graph/outlook-large-attachments?tabs=http
What a mare! But anyway I am posting MIME content as below:
https://learn.microsoft.com/en-us/graph/outlook-send-mime-message
ie. I'm posting plain text content like below to graph's sendMail endpoint
From: Some One <someone#example.com>
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="XXXXboundary text"
Subject: This is a test
This is a multipart message in MIME format.
--XXXXboundary text
Content-Type: text/plain
this is the body text
--XXXXboundary text
Content-Type: text/plain;
Content-Disposition: attachment;
filename="test.txt"
this is the attachment text
--XXXXboundary text--
I don't understand how this would work with the upload-session aproach - so is it possible, and if so, how, can I send MIME content > 4MB using the graph api?
Delphi 10 Seattle
IntraWeb 15.0.23
Chilkat Trial
Used Chilkat (Delphi DLL) PDF File Encoding to Base64 to Encode my file.
https://www.example-code.com/delphidll/base64_pdf.asp
While parsing it to the Chilkat Delphi DLL code to request remote signing I get the below mentioned response.
https://www.example-code.com/delphidll/docusign_request_signature_via_email.asp
Please see Response code while trying to send a file through the Docusign API. I have the PDF to base64 code working and vice versa.
Response Status Code = 400
Response Header:
Cache-Control: no-cache
Content-Length: 226
Content-Type: application/json; charset=utf-8
Date: Wed, 27 May 2020 12:12:16 GMT
Response Body:
{
"errorCode": "UNSPECIFIED_ERROR",
"message": "The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. "
}
Response Body End
Request Body:
{"emailSubject":"DocuSign REST API Quickstart Sample","emailBlurb":"Shows how to create and send an envelope from a document.","recipients":{"signers":[{"email":"123#gmail.com","name":"XYZ","recipientId":"1","routingOrder":"1"}]},"documents":[{"documentId":"1","name":"C:\Doe_John.pdf","documentBase64":"JVBERi0xLjQNJabpz8QNCjEgMCBvYmoNPDwvQ3JlYXRvcij+/wBNAGkAYwByAG8AcwBvAGYAdAAgAFcAbwByAGQAIAAtACAARABvAGMAdQBtAGUAbgB0ADEpL1Byb2R1Y2VyKP7/AFMAYwBhAG4AUwBvAGYAdAAgAFAARABGACAAQwByAGUAYQB0AGUAIQAgADUpL0NyZWF0aW9uRGF0ZShEOjIwMDkxMjIyMTUwOTMyLTA1JzAwJykvTW9kRGF0ZShEOjIwMDkxMjIyMTUwOTMzLTA1JzAwJykvQXV0aG9yKP7/AGUAcwBmAG8AeCkvVGl0bGUo/v8ATQBpAGMAcgBvAHMAbwBmAHQAIABXAG8AcgBkACAALQAgAEQAbwBjAHUAbQBlAG4AdAAxKT4+DWVuZG9iag0yIDAgb2JqDTw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAzIDAgUi9QYWdlTW9kZS9Vc2VOb25lL091dGxpbmVzIDcgMCBSL01lé© "}],"status":"sent"}
Your error message is very helpful in this case. Check the validity of your Base64 string - Looks to me like a pipe and mandarin character sitting at the end of your encoded string.
{ "errorCode": "UNSPECIFIED_ERROR", "message": "The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. " }
I have a endpoint I want to test out. I'll call GET with it and it's supposed to download a zip file containing a csv file. I want to verify that the contents of that csv file is correct.
When I hit the endpoint in Postman, the headers look something like this:
content-disposition: "attachment; filename=filename.zip"
content-encoding: gzip
content-length: 4321
content-type: "application/zip"
vary: Accept-encoding
On the Rest-Assured response though, when I printed out response.contentType(), I got text/html; charset=utf-8. I was going to try to try to get the response byte in bytes[] and then see if it matches the content I'm expecting in the CSV file but since the content-type doesn't match what I'm expecting, I don't think I can do that.
Also, how do I check the content-disposition of my response?
RequestResult strReq = OAuthUtility.Put(
"https://content.dropboxapi.com/1/files_put/auto/",
new HttpParameterCollection {
{"access_token",MYAccessToken},
{"path",Path.Combine(this.CurrentPath, Path.GetFileName(#"C:\test\jj.kk\Downloads\1990480.jpg")).Replace("\\","/")},
{"overwrite","true"},
{"autorename","true"}
}
);
I am using above code for uploading file on Dropbox but giving following error:
The remote server returned an error: (400) Bad Request.
RequestResult : { "error": "Content-Type (application/x-www-form-urlencoded) may not be one of (\'application/x-www-form-urlencoded\', \'multipart/form-data\')" }
Httpheader :
{Transfer-Encoding: chunked
Connection: keep-alive
X-Dropbox-Request-Id: 4029d2ae041cf1f25d8f58d06d158b83
X-Robots-Tag: noindex, nofollow, noimageindex
Content-Type: application/json
Date: Fri, 07 Oct 2016 15:24:17 GMT
Server: nginx
}
Is there any other way of uploading files on Dropbox in ASP.NET?
The error message you're getting is indicating that the issue with your API request is that the Content-Type has an unexpected value. That is, you (via the library you're using, presumably) are sending application/x-www-form-urlencoded. That isn't an allowed format for the Dropbox API /1/files_put endpoint, which expects the raw file data in the body of the request.
To answer your actual question though, there is another way to upload to Dropbox in ASP.NET. You can use Dropbox API v2, instead of Dropbox API v1 as you have here. (And in fact you should, since Dropbox API v1 is deprecated.)
To do so, we highly recommend using the official SDK:
https://www.dropbox.com/developers/documentation/dotnet
Alternatively, you can use the HTTP endpoints directly, e.g.,:
https://www.dropbox.com/developers/documentation/http/documentation#files-upload
In my Blackberry java native application, i am making a call to a dotnet web service whose Request and Response format is defined as below. Here In response XML is being returned. I have been searching the forums and trying for 2-3 days but no success...
Request format :
POST /cinews.asmx/GetSeatLayout HTTP/1.1
Host: webservices.mclients.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
strCinews=string&strTransId1=string&lngSessionId=string&blnScreenOnTop=string&strMergeOption=string&strAreaCats=string
Response format :
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
xml