Skip to main content
Hi All,

My requirement is to create a record for on object & its related attachment in salesforce from php. So for that i created one webservice class & method exposed it .From php side we can able to pass parameters(fields) & record aslo created in salesforce , But How could we pass files which will going to store in the attachment of that record? what should i do to accept that file in my class?
4 respuestas
  1. 31 mar 2015, 23:03

    Subhranshu - You can pass the base64/ blob content of the file in the web service. As an example, I created a small web service class:

    global class WebServiceClass {

    webService static String insertAttachment(String parentId, Blob body, String name) {

    Attachment att = new Attachment();

    att.Name = name;

    att.Body = body;

    insert att;

    return att.Id;

    }

    }

    The above would generate the WSDL that would contain the blobl paramter as below:

    <xsd:element name="body" type="xsd:base64Binary" nillable="true"/>

    From PHP, you would then pass the base64 value of the file in the "body" attribute of the XML.

    Let me know if this solves your problem. Don't forget to mark it solve to benefit others :)

    Regards,

    Varun.
0/9000