Postman file upload boundary - rest

I'm trying to upload a file with my REST POST request. It is not working out. When i try to look at the request postman give:
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 44262
Content-Type: multipart/form-data; boundary=--------------------------085877645320272030820682
Host: localhost
Why there is a boundry? why postman doesn't return the file that i uploaded?

Adding an attachment as 'binary' would solve the POST request problem in your case.
If you would like to download the same attachment, there should be an GET request towards the API.
If that doesn't solve, you should describe your issue better with some pictures to understand better.

Related

How to upload a Salesforce File using REST API properly?

GET /services/data/v47.0/sobjects/ContentVersion/0000v00000MFIVgAAP/VersionData from this request I will get binary file content, but how can I use this content to recreate the file properly (using request to POST /services/data/v47.0/sobjects/ContentVersion)?
I uploaded .docx through the UI and fetch its content.
Then I uploded that content using the request:
Endpoint
/services/data/v47.0/sobjects/ContentVersion
Headers
Content-Type:multipart/form-data; boundary=boundary_string
Accept: application/json
Body
--boundary_string
Content-Disposition: form-data; name="entity_content";
Content-type: application/json
{"PathOnClient":"MyFile.docx"}
--boundary_string
Content-Type: application/octet-stream
Content-Disposition: form-data; name="VersionData"; filename="MyFile.docx"
Binary data from the request to GET /services/data/v47.0/sobjects/ContentVersion/0000v00000MFIVgAAP/VersionData.
--boundary_string--
The request above is executed with a success status code, and the file was created successfully, but when I downloaded this file from UI, it became damaged :(
There may be something in the request body that I missed (but I don’t know what exactly is wrong), so the file creates damaged.

What exactly is sent when a RESTful request is sent. How is the information in the METHOD and BODY sent to the URL?

trying to understand more about RestFul calls. I understand the format, but what I want to know is how the call is actually sent. For example, if I were to setup Fiddler on my client, and I were to make a RestFul call to http:/thisplace.com/rws with Method = POST and Body = Login HTTP/1.1
Host: client.mydomain.com
Accept: application/xml
Content-type: application/xml
What exactly do I see being sent out from the client on fiddler? Is the information coded inside the URL?
Wondering if RestFul calls can be sent without a third-party tool such as PostMan.
RestFul services use standard HTTP methods (GET, POST, PUT, DELETE, etc). The parameters in a HTTP POST request are sent in the request body which appears after the headers. The information/parameters are not encoded in the URL in a POST request.
The format that the parameters are sent depends on the Content-Type of the request.
In your example you specify content-type: application/xml which means you'd need to provide xml in the request body. In fiddler an HTTP POST to http://thisplace.com/rws might look something like this (for application/xml):
POST http://thisplace.com/rws HTTP/1.1
Content-Type: application/xml
Accept: application/xml
Host: thisplace.com
content-length: 64
<myData>
<value>hello</value>
<value2>world</value2>
</myData>
The request body is below the headers and is the after the blank line where you see the xml.
If you specified application/json the parameters would be encoded as json, and the request body might look like:
{
"value1": "hello",
"value2": "world"
}
For content type application/x-www-form-urlencoded the parameters would be in the same format as a query string and the request body might look like:
value1=hello&value2=world
Yes, RestFul calls can be made without postman but you haven't specified which language/technology you're using or how you'd like to send the requests.

Different Responses from Insomnia and Postman for a WebRequest

I am using Postman Tool and Insomnia(Hurl.eu) Tool to make a Particular webRequest.
I get the Response 200 from Insomnia but i am getting 403 Forbidden error from Postman.Here are the Preview messages from both
Postman:
POST /ccadmin/v1/login HTTP/1.1
Host: ccadmin-test-XXXX.oracleoutsourcing.com:443
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.NlCxWPgJAizSO60YeIBQRjgrYlgUhywr8vmnIca69A=ehkZS1iMzUyLWZkNmE1ODM1ZDM3NSIsImlzcyI6ImFwcGxpY2F0aW9uQXV0aCIsImlyJleHAiOjE1MDU4MzQ5NjIsInN1YiI6ImRiZTYwMGFkLWQwNjYtNDhdCI6MTQ3NDI5ODk2Mn0=.
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
Insomnia(Hurl):
POST /ccadmin/v1/login HTTP/1.1
Host: ccadmin-test-XXXX.oracleoutsourcing.com:443
Accept: */*
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.NlCxWPgJAizSO60YeIBQRjgrYlgUhywr8vmnIca69A=ehkZS1iMzUyLWZkNmE1ODM1ZDM3NSIsImlzcyI6ImFwcGxpY2F0aW9uQXV0aCIsImlyJleHAiOjE1MDU4MzQ5NjIsInN1YiI6ImRiZTYwMGFkLWQwNjYtNDhdCI6MTQ3NDI5ODk2Mn0=.
Content-Length: 29
Both request looks similar ,but i am getting 2 different responses.
I also disabled Postman Settings->
i)Send Postman Token Header
ii)Send no-Cache Header
I hope this will help you.
I have found that sometimes Postman behaves a bit weird when you are using Bearer Authorization, this since they made an update to the app and added the "Authorization" tab.
This has happened to me more than ones, specially on pre existing collection.
Let's give it a shot.
Delete the Authentication key on your header, I can see you wrote that one manually. And lets Postman handle that.
Open the Authorization tab, select the Bearer token type from the dropdown, add your token on the window in the left side.
Click on Preview Request.
Now you should be able to see the token on the headers "greyed out"
Open the console, this will help you checking the request and maybe you will find an adicional error.
On the console you can check the raw request and response, it helps.
Also you should try making a request from your machine using CURL ‘yes you can usit on windows and mac’, this way you can discard that you have a closed port.
Good luck

Emails not sending when requesting signatures for DocuSign API

I have written the following two methods for sending requests for signatures.
From template: https://github.com/wadewegner/docusign-sample/blob/master/src/DocuSign/DocuSignClient.cs#L215
From binary: https://github.com/wadewegner/docusign-sample/blob/master/src/DocuSign/DocuSignClient.cs#L152
Both work great and I can see they are out for signature:
The trouble is receiving the email requesting the signature is spotty at best. Early on in my testing it seemed I'd (mostly) get the email, but a couple days in and I haven't received any of the emails you see in the image above.
I'm using a developer sandbox. Is there some kind of restriction?
Also, it seems sending to a different email address from the one I registered is particularly problematic. Are there even more restrictions?
Thank you!
Edit: adding additional info requested.
REQUEST #1 (posting document):
POST https://demo.docusign.net/restapi/v2/accounts/892965/envelopes HTTP/1.1
X-DocuSign-Authentication: <DocuSignCredentials>...</DocuSignCredentials>
Accept: application/json
Content-Type: multipart/form-data; boundary="BOUNDARY"
Host: demo.docusign.net
Content-Length: 91206
Expect: 100-continue
--BOUNDARY
Content-Type: application/xml; charset=utf-8
Content-Disposition: form-data
<envelopeDefinition xmlns="http://www.docusign.com/restapi"><emailSubject>DocuSign API - Signature Request on Document</emailSubject><status>sent</status><documents><document><documentId>1</documentId><name>test.pdf</name></document></documents><recipients><signers><signer><recipientId>1</recipientId><email>wade.wegner#gmail.com</email><name>Wade Wegner</name><tabs><signHereTabs><signHere><xPosition>100</xPosition><yPosition>100</yPosition><documentId>1</documentId><pageNumber>1</pageNumber></signHere></signHereTabs></tabs></signer></signers></recipients></envelopeDefinition>
--BOUNDARY
Content-Disposition: form-data; name=test; filename=test.pdf; filename*=utf-8''test.pdf
<truncating binary>
REQUEST #2 (from template):
POST https://demo.docusign.net/restapi/v2/accounts/892965/envelopes HTTP/1.1
X-DocuSign-Authentication: <DocuSignCredentials>...</DocuSignCredentials>
Accept: application/json
Content-Type: application/xml; charset=utf-8
Host: demo.docusign.net
Content-Length: 421
Expect: 100-continue
<envelopeDefinition xmlns="http://www.docusign.com/restapi"><status>sent</status><emailSubject>DocuSign API - Signature Request from Template</emailSubject><templateId>29CB97E5-DCE1-4C14-91A8-A8317BCD29AD</templateId><templateRoles><templateRole><name>Wade Wegner</name><email>wade.wegner#gmail.com</email><roleName>Signing Role</roleName><clientUserId>1</clientUserId></templateRole></templateRoles></envelopeDefinition>
The ClientUserId causes a recipient to be an embedded recipient. If you provide a value then DocuSign will not send emails. The expectation is that you are going to handle the communication with the signer. This allows you to embed the signing experience within your own website or application.
I think without a trace of your JSON it's hard to figure out where the problems are. One problem could be that you create the envelope in the "created" instead of "sent" state. Another problem could be that you are providing a "clientUserId" which signals to our system that you are embedding the signing experience.
Why don't you get the status on the envelopes where you think you didn't get the e-mail and see what it looks like.
-mb

What is the correct response code when no content is POSTed to a REST resource that expects content?

What is the correct response code when no content is POSTed to a resource that expects content?
POST http://localhost:10545/api/tokens HTTP/1.1
User-Agent: Fiddler
Host: localhost:10545
Content-Type: application/json
Content-Length: 0
The response in this case would be a '400 Bad Request'.
400 Bad Request
The request had bad syntax or was inherently impossible to be satisfied.