Example not the format for Request raw Body for uploading a File in google drive API - google-drive-api

Whatever data I want to send whether be a text file or a PDF am able to give but how do I give my desired name to the file ?? And what about other types of files ?? What should be the request header please give an example had a look at the API documentation but not getting it ...

It seems you're using a basic upload.
You can use the suggested answer in this SO post:
Use multipart upload and specify the tile in the metadata part
{
"title": "My File"
}
Types of files are called MiME types. You can see the supported MiME types here.
Check this Multipart Upload guide for more info.

Related

Logic Apps + Form Recognizer unable to send PDF to service

I have an Azure Logic App that uses a Analyze Document for Prebuilt or Custom models (v3.0 API) action. The Custom Model is good, I can hit it with Postman with no issue.
When I try to get a PDF from Sharepoint and send it to the service, I get an error saying:
{
"error": {
"code": "InvalidRequest",
"message": "Invalid request.",
"innererror": {
"code": "InvalidContent",
"message": "The file is corrupted or format is unsupported. Refer to documentation for the list of supported formats."
}
}
}
I've tried:
Passing the Get file content directly to the Document/Image File Content input
Passing body('Get_file_content)['$content']
Passing concat('data:application/pdf;base64,',body('Get_file_content')['$content']
This one converts to PDF in a Base64-to-PDF tool so I know the Base64 is good
Then I found out that the service wants binary format:
Passing base64ToBinary(body('Get_file_content')['$content'])
Still no go
Why can I not send the file to the Form Recognizer service?
EDIT:
Thank you to #vijaya. They helped me see that the Document/Image URL parameter was not necessary. Leaving that blank and using the original Get File Content worked!
Issue is with content-type. You need to pass content-type along with content for analyze document. I have reproduced issue from my side and below are steps I followed,
Initially created logic app as shown below,
Logic app failed with error,
The file is corrupted or format is unsupported. Refer to documentation for the list of supported formats.
Next modified logic app as shown below,
In Compose action setting content as
outputs('Get_blob_content_(V2)')?['body']?['$content'] and passing content-type as application/pdf as we are dealing with pdf files.
In Analyze Document for Prebuilt or Custom models (v3.0 API) action, using outputs of compose in Document/Image File Content.
Logic app ran successfully as shown below,
Output of Analyze Document is as shown below,

Issue while upload/send file with post request using Jmeter

I have one post request where I am uploading image as per below using postman :
I am trying to perform same request using Jmeter. I did following setting in Jmeter :
But somehow it is not working. I tried with multipart/form-data for POST option also but no luck.
our API developer has set validation that if api get any other file then image then they send response : invalid file type. I am getting this response all time when do POST request with image from Jmeter. It works fine with postman.
In Debugger post processor it shows like this : HTTPsampler.Files=path:'C:\apache-jmeter-4.0\bin\samplex.png'|param:'fileName'|mimetype:'image/png'
Finally I was able to resolve issue by removing Parameter name and MIME Type from tab File Upload. I did provide only file path and it works. Also I unchecked Use multipart/form-data for POST
You see button Browse.. in picture 2 you post. Do for same with Postman, choose file and send the request.
Make sure you have a valid file at the specified path.
Check your postman whether it is sending any other things in the header like Content-Type.
Check out File Uploads using JMeter guide for more information on simulating file uploads with JMeter
As I wrote in comment, If you want to send binary file as is (not as parameter value), remove the Parameter Name column value (file)
See JMeter's HTTP Request reference for more details:
File Path: Name of the file to send. If left blank, JMeter does not send a file, if filled in, JMeter automatically sends the request as a multipart form request.
If it is a POST or PUT or PATCH request and there is a single file whose 'Parameter name' attribute (below) is omitted, then the file is sent as the entire body of the request, i.e. no wrappers are added. This allows arbitrary bodies to be sent. This functionality is present for POST requests, and also for PUT requests.

Issue with attachments in ui5 application having Notes database as the backend

I am developing an application in ui5. The 'Model' is a notes database. Now, I am fetching the notes document via JSON. I want to display the attachments in the upload collection in ui5. The JSON is returning attachments but I am unable to understand it. For e.g. I have attached a PDF document, but the JSON is showing as if I have attached 3 different files. Also the file is in Base64 format.
I want to be able to download and upload the attachments.
Following is the attachment field details in the JSON(There is only 1 file "Domino Access Service.pdf" in the field and nothing else):
"Attach_ProductDetails":
{
"type":"multipart",
"content": [
{
"contentType":"multipart\/mixed; Boundary=\"0__=4EBB0B01DFD9A4D28f9e8a93df938690918c4EBB0B01DFD9A4D2\""
},
{
"contentType":"multipart\/alternative; Boundary=\"1__=4EBB0B01DFD9A4D28f9e8a93df938690918c4EBB0B01DFD9A4D2\"",
"boundary":"--0__=4EBB0B01DFD9A4D28f9e8a93df938690918c4EBB0B01DFD9A4D2"
},
{
"contentType":"text\/plain; charset=US-ASCII",
"data":" (See attached file: 1. Domino Access Service.pdf)",
"boundary":"--1__=4EBB0B01DFD9A4D28f9e8a93df938690918c4EBB0B01DFD9A4D2"
},
{
"contentType":"text\/html; charset=US-ASCII",
"contentDisposition":"inline",
"data":"<html><body><i>(See attached file: 1. Domino Access Service.pdf)<\/i><\/body><\/html>\r\n",
"boundary":"--1__=4EBB0B01DFD9A4D28f9e8a93df938690918c4EBB0B01DFD9A4D2"
},
{
"contentType":"application\/pdf; name=\"1. Domino Access Service.pdf\"",
"contentID":"<1__=4EBB0B01DFD9A4D28f9e8a93df93869091#local>",
"contentDisposition":"attachment; filename=\"1. Domino Access Service.pdf\"",
"contentTransferEncoding":"base64",
"data":"<Base64 data>",
"boundary":"--0__=4EBB0B01DFD9A4D28f9e8a93df938690918c4EBB0B01DFD9A4D2"
}
]
}
It will be great help if anyone has the solution for the same.
It is not giving you three files. It is showing you two alternative renderings of the rich text field called Attach_ProductDetails which contains the icon representing the attached file - which it thinks you might want. There could also be other data in that rich text field. The API has no idea what part of it you want, so it gives you everything - and in case you're not prepared to deal with text/html it also gives you a text/plain rendering, too.
It is also giving you the file attachment data, tagged with the "application/pdf" content-type. You need to decode the base64 data and store it so you can display it (or whatever else your application wants to do with it).

How to transfer large xml file and zip file via rest api?

I have an application which uploads a large file in the XML format and sometimes a zip file. Now I want to have that file transferred to other application via REST API. I am thinking to pass the binary data in to json response.
I have the following questions for my approach.
Is sending binary in json the best approach/practice to do it?
Will this be PUT scenario as receiver application doesn't know about new uploaded file?
If that makes it easier for the second service to consume it, I see no problem with it. You can send it on any format you want, as long as it's accepted and you're setting the Content-Type and Accept headers properly.
You use a PUT only when you're sending a complete replacement of the resource at the target URI. If you know the final URI for that and if a GET to the same URI right after the PUT will retrieve as response the same body you just submitted, it makes sense to use PUT, otherwise, use a POST.

API 2.0 how to upload file with POSTMAN?

I'm reading API 2.0 documentation and try using POSTMAN (recommended in the documentation).
In "Upload a file" section, I got "404 not found" error.
for example:
{"type":"error","status":404,"code":"not_found","help_url":"","message":"Unknown Error","request_id":"11139828924fa91c0d283d2"}
POSTMAN window image is here.
Base URL is tring "upload.box.com/api/2.0" (temporary, according to the document).
What's wrong?
One more point, your POSTMAN request misses to indicate folder_id in its form data . You need that "folder_id" value for the request to work .
The domain specific Upload issues have all been resolved. You can now direct all API requests, including uploads, to https://api.box.com/2.0