Skip to Content

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

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?


Sankaran A

Add comment
10|10000 characters needed characters exceeded

  • Former Member

    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


  • Get RSS Feed

3 Answers

  • Best Answer
    Nov 21, 2016 at 05:43 PM

    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


    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • avatar image
    Former Member
    Nov 21, 2016 at 01:24 AM

    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,


    Add comment
    10|10000 characters needed characters exceeded

  • Nov 21, 2016 at 12:58 PM

    Hello Sankaran,

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


    Add comment
    10|10000 characters needed characters exceeded