Skip to main content
Participant
October 11, 2023
Question

Invalid Token on Uploading Asset

  • October 11, 2023
  • 0 replies
  • 191 views

I'll just start this off by saying that I'm trying to accomplish this through Zoho CRM using their scripting language Deluge and the Rest API commands. 

 

We are just getting started using the PDF Services API, walking through the authentication process, and uploading the asset.  We're able to get our access token, then the uploadUri and assetID, but when we go to upload a file to the uploadUri we get a response code 400..
- InvalidToken

- The provided token is malformed or otherwise invalid

 

We did figure out that once we get the initial response with the uploadUri and assetId, we have to decode the url before trying our POST of the file.  If we don't decode the url, the error is "SignatureDoesNotMatch", if we do decode it, "InvalidToken".

 

I've posted the code below if that helps, but again it's in Zoho Deluge. 

 

Any help is appreciated! 

 

adobeTokenUrl = "https://pdf-services.adobe.io/token";
adobeHeader = Map();
adobeHeader.put("Content-Type","application/x-www-form-urlencoded");
adobeParams = {"client_id":adobeClientId,"client_secret":adobeClientSecret};
getAdobeToken = invokeurl
[
	url :adobeTokenUrl
	type :POST
	parameters:adobeParams
	headers:adobeHeader
	detailed: true
];
adobeKey = getAdobeToken.get("responseText").get("access_token");
// info adobeKey;
//
// Upload to Adobe
adobeUploadUrl = "https://pdf-services.adobe.io/assets";
uploadHeader = {"X-API-Key":apiKey,"Authorization":"Bearer " + adobeKey,"Content-Type":"application/json;charset=UTF-8"};
uploadParam = {"mediaType":"application/pdf"};
//
uploadToAdobe = invokeurl
[
	url :adobeUploadUrl
	type :POST
	parameters :uploadParam.toString()
	headers :uploadHeader
];
//info uploadToAdobe;
uploadUri = uploadToAdobe.get("uploadUri");
assetID = uploadToAdobe.get("assetID");
//
// Decode the Uri
decodeUri = zoho.encryption.urlDecode(uploadUri);
//info decodeUri;
//
fileUploadHeader = Map();
fileUploadHeader.put("Content-Type","application/pdf");
fileUpload = invokeurl
[
	url :uploadUri
	type :PUT
	parameters :convertedFile
	headers :fileUploadHeader
	detailed :true
];
info "File Upload Response: " + fileUpload;

 

This topic has been closed for replies.