This discussion is archived
6 Replies Latest reply: Nov 9, 2011 6:54 AM by 781825 RSS

Adding attachment via XML calls

810929 Newbie
Currently Being Moderated
I am trying to associate an attachment to a punch list item via XML in C#. Whenever I try to insert an Attachment object, I am getting a generic 'Error' message back. The XML is properly formed and I am populating it with values in the same locations as a file attached via the Contract Management interface. The code to insert the punch list item works fine and it appears in the CM interface. Does anyone have any experience with this scenario? Note: I am uploading the physical file separately.
  • 1. Re: Adding attachment via XML calls
    810929 Newbie
    Currently Being Moderated
    Update on this: I have also tried to pass the attachment as a binary in the XML call. This also fails with the generic error. Any ideas or help would be very much appreciated.
  • 2. Re: Adding attachment via XML calls
    rm22 Explorer
    Currently Being Moderated
    To clarify: Are you using the API? If so, then I assume you are sending an INSERT request with sys_item_type of DLNK.

    What values are coming back in the following return XML?

    <response responseCode="1">

    <message>Document added successfully</message>

    Would you find posting the sample XML you are using for the INSERT?
  • 3. Re: Adding attachment via XML calls
    810929 Newbie
    Currently Being Moderated
    Yes, I am using INSERT for a DLINK object.

    The return is:
    <response responseCode="-1">

    <message>Error</message>

    One sample of the XML is:
    <?xml version="1.0"?><request xmlns="http://app.expedition.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://app.expedition.com/ https://<expedition_server>/exponline/xml-schemas/request.xsd"><header sysitemtype="DLNK" requestType="DETAIL"><sessionId>4d18ffb7a80a47bc88223b2a8f</sessionId><action>INSERT</action><getUpdatedDataInResponse>true</getUpdatedDataInResponse></header><DLNK><attachment></attachment><base_item_type>PUN</base_item_type><base_master_key>e71f5b8605284aab9438dfadcd</base_master_key><base_parent_key></base_parent_key><base_sys_item_type></base_sys_item_type><created_by></created_by><created_date></created_date><created_system></created_system><date_linked></date_linked><file_size></file_size><is_a_url>False</is_a_url><item_type></item_type><last_edit_by>hatch</last_edit_by><last_edit_date>11/9/2010 4:22:33 PM</last_edit_date><last_edit_system></last_edit_system><linked_by_user></linked_by_user><linked_by_user_name></linked_by_user_name><location></location><master_key></master_key><project_name></project_name><sender_login_name></sender_login_name><subject></subject><sys_item_type>DLNK</sys_item_type></DLNK></request>


    I have actually tried a variety of combinations with the data population with no success. Thanks for any hints you can provide.
  • 4. Re: Adding attachment via XML calls
    719817 Newbie
    Currently Being Moderated
    Here is an example of one that worked here. A couple comments on yours. I did not see a Base_sys_item_type in your code. Which I believe is required for this table. Usually whan I have a question about what data I need to send I'll add a record manually then duplicate what I see in the table. Another thing you should know is that the API will not receive actual files. All it currently does is create links. Files still need to be placed in the correct location. I do that here using some code that copies the files to the correct location when we load in bulk.

    We are using CM on some huge projects. I have used the API to integrate and to add/delete/update hundreds of thousands of records. Each module seems to be slightly different, so be wary and always test if/how the API works. Each type can have it's own unique list of required fields etc..


    <?xml version="1.0" encoding="UTF-8"?><request xmlns="http://app.expedition.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://app.expedition.com/ http://127.0.0.1/exponline/xml-schemas/request.xsd"><header requestType="DETAIL" sysitemtype="DLNK"><sessionId>000TfQLKK1000630000000BURN</sessionId><action>INSERT</action><getUpdatedDataInResponse>true</getUpdatedDataInResponse></header><DLNK>
         <attachment>J:\data\<Attachment Name>.PDF</attachment>
         <base_item_type>SNT</base_item_type>
         <base_master_key>0002YOCBJ0727800000000BURN</base_master_key>
         <base_parent_key></base_parent_key>
         <base_sys_item_type>SNT</base_sys_item_type>
         <created_by></created_by>
         <created_date></created_date>
         <created_system></created_system>
         <date_linked>2009-02-03T12:00:00.0000000</date_linked>
         <file_size>0</file_size>
         <is_a_url>0</is_a_url>
         <item_type>DLNK</item_type>
         <last_edit_by></last_edit_by>
         <last_edit_date></last_edit_date>
         <last_edit_system></last_edit_system>
         <linked_by_user>Joe Manzi</linked_by_user>
         <linked_by_user_name>Joe Manzi</linked_by_user_name>
         <location></location>
         <master_key></master_key>
         <project_name>"Your Project name"</project_name>
         <sender_login_name></sender_login_name>
         <subject>test</subject>
         <sys_item_type>DLNK</sys_item_type>
    </DLNK></request>
  • 5. Re: Adding attachment via XML calls
    810929 Newbie
    Currently Being Moderated
    Thank you for getting back to me.

    Chrispy_BMCD wrote:
    I did not see a Base_sys_item_type in your code. Which I believe is required for this table. Usually whan I have a question about what data I need to send I'll add a record manually then duplicate what I see in the table.
    I agree - I do the exact same thing. I did replicated it and it did not include the base_system_item_type. I have tried it with and without that data.
    Chrispy_BMCD wrote:
    Another thing you should know is that the API will not receive actual files. All it currently does is create links. Files still need to be placed in the correct location. I do that here using some code that copies the files to the correct location when we load in bulk.
    We are uploading the file directly. However that does present us with another question, the client is using SharePoint as their repository. We are uploading directly to SharePoint however do we need to upload to Expedition first? Perhaps this is part of the our problem.

    Thanks again!
  • 6. Re: Adding attachment via XML calls
    781825 Newbie
    Currently Being Moderated
    My Issue is client is using sharepoint to upload the files, Please what are the step i should take,
    I want to use XML API for that

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points