cancel
Showing results for 
Search instead for 
Did you mean: 

Storing String data in Binary Object - Need to store a PDF-File from Webservice as an attachment.

Former Member
0 Kudos

Hi Experts,

Please loot at my bellow code.

// Webservice Reponse, already base-64 converted, No need to convert again.
var ReponseString = ws_result.Content; 
var binaryString : BinaryObject;
this.binaryData.content = ReponseString ;
//Warning.  ReponseString  is having value. Debugging: Empty value return.

Is there any other way to store string in binary object? Am I missing anything in above code?

Regards

Sankaran A

Former Member
0 Kudos

Hi Sankaran,

please did you found a solution how to resolv this issue?

i'm facing the same problem and i laking ideas, please let me know if you have found a solution.

Best Regards

Stéphane

Accepted Solutions (1)

Accepted Solutions (1)

marlosdamasceno
Participant

Hi Sankaran,

You said that your return from the web service is already on Base64. Did you try the follow:

var docType : DocumentTypeCode;
var binaryObject : BinaryObject;
var docDesc : Description;
var docName : LANGUAGEINDEPENDENT_Name;
var docAltName : LANGUAGEINDEPENDENT_Name;
docAltName = "altName";

var ReponseString = ws_result.Content; 
docName = "NameOfDoc.pdf";		
docDesc.content = "Your description of the document";
docType.content = "10001"; /*Standard Attachment*/
binaryObject.mimeCode = "application/pdf";	

/*Here is the important line*/	
binaryObject.content = Binary.ParseFromBase64String(ReponseString); 
this.AttachmentFolder.CreateFile(docType, docName, docAltName, docDesc, binaryObject);	

I hope this help

Regards

Former Member

Thank you much @Marlos

Regards

Sankaran A

marlosdamasceno
Participant
0 Kudos

You are welcome Sankaran!

Best regards

Former Member
0 Kudos

Hi Augustus,

i even use your proposition but i still get a failure when i try to read the pdf file with Acrobat Reader DC

Best Regards

Stephane.

marlosdamasceno
Participant
0 Kudos

Hi Stephane,

I have to make sure that your string is in base64, otherwise it will generate an error. You may try to convert an PDF file to a Base64 string (here). And, use this hard coded string to check if the parser on C4C was ok.

I did no try to do this, but it may work and give you an direction to go.

Best regards

Marlos Damasceno

Answers (2)

Answers (2)

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Sankaran,

What about using the DO AttachmentFolder?
Just use the action CreateFile which supports a parameter DocumentFileContentBinaryObject.

HTH,
Horst

Former Member
0 Kudos

Hi Horst,

Thanks a lot. It is working.

Regards

Sankaran A

Former Member
0 Kudos

Hi Sankaran,

I also encountered the same problem.

You can try WebServiceUtilities.EncryptWithHashBasedMessageAuthenticationCode() the method.

Unfortunately,I did not find the relevant documents about the method paraments.

Thanks and Regards,

Eric

Former Member
0 Kudos

Hi Eric,

Thanks for your feedback.

Regards

Sankaran A