Skip to main content
Participant
August 14, 2026
Question

Error 400 returned when trying to get presigned uri for pdf upload

  • August 14, 2026
  • 0 replies
  • 4 views

I am developing server to server app to export a pdf to Adobe and get text back after OCR run.

I can get the OAuth token just fine according to Step1 in the API docs. When I try to get a presigned URI which is used to upload the PDF that I want to extract text frrom, I get HTTP Error 400. The “text” that is returned in the JSON data from the call to the server is some simple HTML that contains the following info “openresty”.  I am not sure I’m calling the correct url to get the presigned URI. 

I’m calling https://pdf-services-ue1.adobe.io/assets which is what the docs say. The “assets” endpoint is implied. Some examples in the help forums call https://pdf-services.adobe.io/assets   which is different.

The examples say to put my client id in the header as X_API_Key. I thought the “X” stuff was depricated years ago. It’s even more mysterious after just using “Client_ID” to get the OAuth token to do the call that is failing. Any way, I’m developing (figuring out how this works) with a Desktop written in Delphi.

Here’s the important code …. remember, this aint production so no criticising …

procedure TMainForm.bGetTargetClick(Sender: TObject);
var
  wkToken, wkTokenType, wkStr, wkURL : string;
  wkHTTPError : string;
  wkError : tstringlist;
begin
  // Get a "pre-signed address and authorization to upload the PDF.
  // Requires a token exists and not expired.
  // Bearer token already set in header when token got.
  
  GetOAuthControl();
  
  wkError := tStringList.Create;
  wkError.Delimiter := ' ';
  
  wkToken := qryOAuthControl.FieldByName('OAuthToken').AsString;  
  wkTokenType := qryOAuthControl.FieldByName('OAuthTokenType').AsString;  
  
  wkURL := 'https://pdf-services-ue1.adobe.io/assets';

  HTTP.ContentType := 'application/json';
  HTTP.Accept := 'application/json';
  
  HTTP.OtherHeaders := 
    'authorization: ' + wkTokenType + ' ' + 
      qryOAuthControl.FieldByName('OAuthToken').AsString +
      #10#13 + 
      'X_API_Key: ' + 
      qryOAuthControl.FieldByName('ClientId').AsString;  

  mLog.Lines.Add(HTTP.OtherHeaders);
    
  // Build JSON to Authorization
  wkStr := '"application/pdf"';
  
  jDoc.Reset;
//  jDoc.StartArray;
  jDoc.StartObject;
  jDoc.PutProperty('mediaType', wkStr, 6); 
  jDoc.EndObject;
//  jDoc.EndArray;

  mLog.Lines.Add(' ');
  mLog.Lines.Add(jDoc.OutputData);

  HTTP.Disconnect;
  HTTP.PostData := jDoc.OutputData;
  
  // Send the Request for that document.
  try
    HTTP.Post(wkURL);
//    HTTP.Get(wkURL);
  except
    on e:exception do begin
      mLog.Lines.Add(e.Message);
      wkError.DelimitedText := HTTP.StatusLine;
      mLog.Lines.Add(' ');
      mLog.Lines.Add('Error: ');
      mLog.Lines.Add(HTTP.TransferredData);
      mLog.Lines.Add(wkError.CommaText);
    end;
    
  end;  

  wkStr := '';
  wkError.Free;
   
end;
 

 

**********************************

Here is the output

 

authorization: bearer eyJhbGciOiJSUzI1NiIsIng1dSI6Imltc19uYTEta2V5LWF0LTEuY2VyIiwia2lkIjoiaW1zX25hMS1rZXktYXQtMSIsIml0dCI6ImF0In0.eyJpZCI6IjE3ODY3MTUxMDkyMTZfMmJhNDZlNDgtOWEyNy00YjRkLWJjMTYtZmRiNDQ0Y2NlYTc1X3VlMSIsIm9yZyI6IjEyNkU4MTY0NkE3Q0E3RDYwQTQ5NUMxQ0BBZG9iZU9yZyIsInR5cGUiOiJhY2Nlc3NfdG9rZW4iLCJjbGllbnRfaWQiOiJmODA4NmI1OWZlNzU0NDYxOGQyODI3ZWM0ZjgzMDUxNSIsInVzZXJfaWQiOiIwRjQ0ODE2NjZBN0NBOEI2MEE0OTVGQ0JAdGVjaGFjY3QuYWRvYmUuY29tIiwiYXMiOiJpbXMtbmExIiwiYWFfaWQiOiIwRjQ0ODE2NjZBN0NBOEI2MEE0OTVGQ0JAdGVjaGFjY3QuYWRvYmUuY29tIiwiY3RwIjozLCJtb2kiOiI0OTE1OTdlZSIsImV4cGlyZXNfaW4iOiI4NjQwMDAwMCIsInNjb3BlIjoiRENBUEksb3BlbmlkLEFkb2JlSUQiLCJjcmVhdGVkX2F0IjoiMTc4NjcxNTEwOTIxNiJ9.EfGg9Bf8Z22u8BImfOCRUm5CFj9SAucP_8G8VkJ6zlhOtxirSZv2FD6WqmP3jt1pcZJIJy8AwfXFhE8JuffPlxPRxowPlRYXcikdhN8CNo5LqiAkvzucD5Gh0rYNPbGpd5gTCm57S1sJg3xsqcZYlVKyOo3QIbEVJFqX3XCey1jDGcJJRoAv27gOAHIuE7fR0V_bHDFEEW5L3bCrnERhahqKQupScyO_nhiQtbWi6XgCFtTOyCOp2H5y9mjpB6U2ejjjDwZkS_DqT57nt9cSe_5wnDoOphaxbTI8At585bfoS0oOizfovbQq2eFUgBr8d6MQ79usltu3YIaDMPFSRg
X_API_Key:  f8086b59fe7544618d2827ec4f830515
 
{"mediaType":"application/pdf"}
151: HTTP protocol error. 400 Bad Request.
 
Error: 
<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>openresty</center>
</body>
</html>

 

It’s some little thing. I changed the say I add the headers to the HTTP object so that they did not have the CRLF seperator when I called the HTTP.OtherHeaders method. That gave me a “Bad Client Id” response which I expected. That implies that my headers are ok at the Adobe server. 

The “openresty” message is hinting to me that Adobe is passing this request to another server and the other server at “openresty” doesn’t like it for some reason.

Has anyone encountered it ?

I use the HTTP object to interface with all sorts of API’s so I’m pretty sure that’s not where the problem lies.

 

Thanks in advance for any help.