Home Self-Service Portal - Community
Options

Upload file with Cireson api

Michael_MyhreMichael_Myhre Premier Partner IT Monkey ✭
I am trying to use the api to upload an attachment, but are not succeeding.

In the api I see Projection/Commit has a parameter for fileAttachmentPath. Is this the one to use? How should it be used?

Answers

  • Options
    Nicholas_VelichNicholas_Velich Cireson Consultant Ninja IT Monkey ✭✭✭✭
    edited July 2017
    I don't believe its currently possible/supported to upload a file attachment via the API. Would be a great feature request though!
  • Options
    Roland_KindRoland_Kind Partner Advanced IT Monkey ✭✭✭
    edited January 2018

    Hi Michael,


    ... a little bit late - but I searched for a solution, too and I developed the following approach which works for me (for creating new WorkItems with attachments / latest 2016 Version of the Portal 8.2.x)

    1) upload files using the following ajax call...

    formData.append('files', dataBlob); 
           $.ajax({
            type: 'POST',
            url: '/FileAttachment/UploadFile/'+workItem.BaseId+'?count='+idx+'&className=System.WorkItem.ServiceRequest',
            data: formData,    

    use the callback data as Input for the pageForm.viewModel.FileAttachment Array

    2) use the following post method to create the workitem

    var postData = encodeURIComponent(JSON.stringify({
           isDirty: true,
           current: workItem       
           }));  

          $.ajax({       
                  
           url: "/ServiceRequest/Save",
           type: "POST",       
           processData: false,
           ContentType: "application/x-www-form-urlencoded; charset=UTF-8",       
           data: "formJson="+postData,


    Hope this helps       

    regards



Sign In or Register to comment.