ksharlandjiev | Posts: 14

HTTP/1.1 415 Unsupported Media Type

0 votes
Hello gurus. I hope you can help me. I'm trying to create a new package in sandbox.esignlive.com, but when I try to upload the document I'm getting: HTTP/1.1 415 Unsupported Media Type Basically I'm trying to reproduce the same calls as you are making in your PHP example, so: 1) I'm creating a package, lets say ID: s0ex3xuyXSxaUT16bzcYcwRr660= 2) Next I'm trying to POST to https://sandbox.esignlive.com/a/api/packages/s0ex3xuyXSxaUT16bzcYcwRr660= where my post is a multipart/form-data containing a pdf and the entire xml including the approvals, and the custom fields. First part is OK, and I'm getting the packageId, but the second transaction is failing. Could you please have a look the logs on your side and let me know what I'm doing wrong? Thanks in advance. Kamen

Approved Answer
harishaidary | Posts: 1812

Reply to: HTTP/1.1 415 Unsupported Media Type

0 votes
Hey Kamen, The reason why you don't see any approval fields in my example is because I used the document extraction feature to extract all the form fields from the PDF. This way, the positioning and sizing of the fields are retained in eSignLive. Unfortunately, I was not able to get a working code in order to create and send a package in one request. I kept getting a 500 error. In my PHP example, if you don't want to use document extraction, and want to position the approvals and fields using x-y coordinates, you can definitely do so. Below is an example json payload you can pass when uploading your document:
{
  "approvals": [
    {
      "role": "Signer1",
      "fields": [
        {
          "page": 0,
          "top": 200,
          "subtype": "LABEL",
          "height": 50,
          "left": 100,
          "width": 200,
          "id": "myLabelField",
          "type": "INPUT",
          "value": "Example label field value"
        },
        {
          "page": 0,
          "top": 100,
          "subtype": "FULLNAME",
          "height": 50,
          "left": 100,
          "width": 200,
          "type": "SIGNATURE",
          "name": "ExampleSignatureId"
        }
      ],
      "name": "Signer1"
    }
  ],
  "id": "sample-contract",
  "name": "Test Document"
}
Let me know if anything is left unclear or if you need more help. I will keep working on trying to get a working PHP code to create and send a package in one request.

harishaidary | Posts: 1812

Reply to: HTTP/1.1 415 Unsupported Media Type

1 votes
Hi Kamen, There are a couple of things I should point out when uploading a document to a package:
  1. the endpoint url you need to make your request to is: https://sandbox.esignlive.com/api/packages/{packageId}/documents (you have it as https://sandbox.esignlive.com/a/api/packages/s0ex3xuyXSxaUT16bzcYcwRr660=)
  2. make sure your accept header is "text/html" and not "application/json"
  3. also make that your content-type header is set to "multipart/form-data"
Hope this helps!

ksharlandjiev | Posts: 14

Reply to: HTTP/1.1 415 Unsupported Media Type

0 votes
Hey, thanks for pointing this out. I've made the changes as per your instructions, but now I've got ERROR 500 when submitting the data. The package ID is: MZlmNgRsJwC6PYulLNRVVs4bxC0= Any idea? Thanks.

harishaidary | Posts: 1812

Reply to: HTTP/1.1 415 Unsupported Media Type

0 votes
Would you be able to share your curl code so I can have a look at it? including the part where you build your json.

ksharlandjiev | Posts: 14

Reply to: HTTP/1.1 415 Unsupported Media Type

0 votes
hmm... this would be very easy in the most languages, but let me see how to do this in delphi.... Meanwhile, maybe you can access this quicker in the server logs? :-o Thanks, Kamen

harishaidary | Posts: 1812

Reply to: HTTP/1.1 415 Unsupported Media Type

0 votes
To get the logs, I will have to open a ticket with support and they will make the request. It usually takes up to one week to get them.

ksharlandjiev | Posts: 14

Reply to: HTTP/1.1 415 Unsupported Media Type

0 votes
Hi Again, will this work for you: http://posttestserver.com/data/2016/06/30/07.34.54626559248 It is a post server, dumping whatever you fire. I did post the second part, the json and the file. Kamen

harishaidary | Posts: 1812

Reply to: HTTP/1.1 415 Unsupported Media Type

0 votes
Hey Kamen, Here's an example of an HTTP request made to eSignLive in order to upload a document to package:
POST /api/packages/f_GegBl2kXc9Bc_H9BYACHsRVNA=/documents HTTP/1.1
Host: sandbox.esignlive.com
Authorization: Basic api_key
Accept: text/html
Cache-Control: no-cache
Postman-Token: 8bd3383b-69dc-c05b-dfd5-5b3c4d58013b
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename=""
Content-Type: 


----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="payload"

{"name" : "Test"}
----WebKitFormBoundary7MA4YWxkTrZu0gW
I've never used delphi before but are you making the POST request using php or delphi? If you are making the request with PHP, would you be able to share your "post.php" file? If you don't want it to be shared on the forums, you can send it to me at [email protected] . If you followed my PHP example, it should be pretty straightforward.

ksharlandjiev | Posts: 14

Reply to: HTTP/1.1 415 Unsupported Media Type

0 votes
Thanks man. I'll try this next week, and post back the results. I hope i can figure this out as it is driving me crazy now. Thank you once again. Kamen

harishaidary | Posts: 1812

Reply to: HTTP/1.1 415 Unsupported Media Type

0 votes
My pleasure. Let me know how it goes :)

ksharlandjiev | Posts: 14

Reply to: HTTP/1.1 415 Unsupported Media Type

0 votes
Hi Haris, Sorry for bothering you again, but I'm testing now with your PHP example, and I'm still not able to get around of what I need. So I have a simple question: Is there ANY way I can create a package that contain 1 PDF document, two approvals with different fields for every approval and I want to make the whole thing with 1 API call only? I was led to believe from your technicians on a pre-sale phone call that this is possible, but now after 2 months of fighting with your API, I'm not so sure. I'm now trying with your PHP example here: https://www.esignlive.com/blog/esignlive-how-to-creating-a-simple-php-web-application/ where you upload a document with some fields, but the reality is that this fields are not visualized anywhere... I've also have tried a ridiculous procedure of: 1) using post: https://sandbox.esignlive.com/api/packages/ --> Got PackageID 2) Create a new document with post: https://sandbox.esignlive.com/api/packages/oN3k3zqrx1zj8EIxkmBpeW2EfuM=/documents --> Got DocumentId 3) Trying to add approvals with their fields wiht put: https://sandbox.esignlive.com/api/packages/oN3k3zqrx1zj8EIxkmBpeW2EfuM=/documents/4f799d26160d8ff8/approvals No luck at all. No matter how I try to use your API I always end up with some problems. The fact that I cant see any error logs or what your system doesn't like is also not the friendliest way of making integration. Your help will be gracefully appreciated. Thanks. Kamen

ksharlandjiev | Posts: 14

Reply to: HTTP/1.1 415 Unsupported Media Type

0 votes
Haris, Good news! It turns out there was 1 field that was with strange top/left values which caused the system to return error 400 BAD Request. After removing this field it is all good. It is all working well now & I’m back on track! Thanks for your help! I will run few more tests, and I hope I wont need to bother you again! Kind regards, Kamen

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off