Author Topic: Save attachment using XMLAPI  (Read 3268 times)

Offline eladfrn

  • Sr. Member
  • ****
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Save attachment using XMLAPI
« on: October 24, 2010, 05:18:39 AM »
Hi all,
I am trying to save a records in support incident attachment using XMLAPI.
I tried this code:
 String strAttachment = Convert.ToBase64String(FileUpload1.FileBytes);
            string sXMLstart = "<?xml version=\"1.0\"?>" +
                                        "<command xmlns=\"urn:schemas-pivotal-com/LifecycleServer50\">" +
                                            "<systemName>HelpDesk</systemName>" +
                                            "<userName>prs</userName>" +
                                            "<loginType>Active Client</loginType>" +
                                            "<saveFormData>" +
                                                "<formUpdate>" +
                                                    "<formName>CF SI Add Attachment</formName>";

            string sXML = "<segmentUpdate>" +
                                "<segmentName>Attachment</segmentName>" +
                                "<primaryUpdate>" +
                                    "<fieldUpdate>" +
                                        "<fieldName>Attachment</fieldName>" +
                                        "<value>" + strAttachment + "</value>" +
                                    "</fieldUpdate>" +
                                    "<fieldUpdate>" +
                                        "<fieldName>Support_Incident_Id</fieldName>" +
                                        "<value>" + supportIncidentId + "</value>" +
                                    "</fieldUpdate>";

            string sXMLend = "</primaryUpdate>" +
                                "</segmentUpdate>" +
                                "</formUpdate>" +
                            "</saveFormData>" +
                        "</command>";

            sXML = sXMLstart + sXML + sXMLend;
            string res = PivotalAPI(sXML);//update the crm

and I got this error:

<?xml version ="1.0"?><commandResult xmlns = "urn:schemas-pivotal-com/LifecycleServer50">
<error>
<errorNumber>80070005</errorNumber>
<errorText></errorText>
<errorDetails>
  HRESULT = 0x80070005 -- Access is denied.
  Function = CRXMLformUpdate::Update
  Occurred in .\RXSaveFormData.cpp on line 608.
  Compiled on Nov 30 2009, modified on Thu Apr 12 15:10:52 2007.
====================

  HRESULT = 0x80070005 -- Access is denied.
  Function = CRSaveFormData::Execute
  Occurred in .\RXSaveFormData.cpp on line 838.
  Compiled on Nov 30 2009, modified on Thu Apr 12 15:10:52 2007.</errorDetails>
</error>
</commandResult>

Any ideas?

Thanks

Offline eladfrn

  • Sr. Member
  • ****
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Re: Save attachment using XMLAPI
« Reply #1 on: November 17, 2010, 01:45:51 AM »
Hi,
I think I got the xml format but still something is wrong and I dont know what:
<command>
<systemName>Con</systemName>
<userName>crm</userName>
<loginType>Active Client</loginType>
<saveFormData>
<formUpdate><formName>CF SI Add Attachmentt</formName>
<segmentUpdate>
<segmentName>Attachment</segmentName>
<primaryUpdate>
<fieldUpdate>
<fieldName>Attachment_Binary</fieldName>
<value fileName='elad.txt'>C:\Documents and Settings\crm\Desktop</value></fieldUpdate>
<fieldUpdate>
<fieldName>Support_Incident_Id</fieldName><value>0000000000001AC4</value>
</fieldUpdate>
</primaryUpdate>
</segmentUpdate>
</formUpdate>
</saveFormData>
<binary>ZWxh</binary>
</command>

and the error is :

<?xml version ="1.0"?><commandResult xmlns = "urn:schemas-pivotal-com/LifecycleServer20">
<error>
<errorNumber>80070057</errorNumber>
<errorText>(12,27) The parameter is incorrect.
</errorText>
<errorDetails>
  HRESULT = 0x80070057 -- The parameter is incorrect.
  Function = CRExileElementFactory::FindAttributeType
....

Any thoughts?

Offline CarlC

  • Hero Member
  • *****
  • Posts: 267
  • Karma: +28/-5
    • View Profile
Re: Save attachment using XMLAPI
« Reply #2 on: May 27, 2015, 07:43:44 AM »
Did you figure this out? Struggling with this now & no support from Aptean