Question

FSM ODATA REST API - ATTACHMENTS

  • 18 March 2021
  • 4 replies
  • 360 views

Userlevel 1
Badge +3

Hi,

 

Does anybody know how to upload attachments from client machine to FSM using FSM ODATA REST APIs?

 

Thanks,

Dananjaya

 


This topic has been closed for comments

4 replies

Userlevel 7
Badge +24

Hi @dadolk,

Are you able to clarify the specific issue you are facing? The FSM ODATA REST API’s are able to handle attachments. There is documentation on the API within FSM found by searching for FSM ODATA REST API’s in the menu search.

It may be worth searching the Community for existing posts as well, I found the below post where people were discussing a particular issue they had with attachments which was solved:

Kind regards,

Lee Pinchbeck

Userlevel 1
Badge +3

Hi @Lee Pinchbeck ,

 

According to the REST API, the file has to be accessible to FSM Server in order to upload. But, it does not say anything about uploading a file from client machine. That is the problem I am facing. 

 

Thanks,

Dananjaya

Userlevel 3
Badge +5

Is it possible to post the base 64 encoded string in the payload? We’ve tried this so many different ways. The ones I thought were closest to working were:

 

POST https://{server}/odata/attachment

 

Option 1 Body:

{

    attachment@odata.mediaEditLink: “:base64encodedimage”,

 

    "attachment_name": "helloworld5.jpg",

    "file_extension": "jpg",

    "file_type": "image/jpeg",

    "stored": "Y",

    "active": "Y",

    "external_access": "N",

    "on_demand": "N",

    "selectable": "Y",

    "solution": "N"

}

 

Option 2 Body:

{

    attachment@odata.mediaEditLink: “”,

    "attachment": “:base64encodedimage,”

    "attachment_name": "helloworld5.jpg",

    "file_extension": "jpg",

    "file_type": "image/jpeg",

    "stored": "Y",

    "active": "Y",

    "external_access": "N",

    "on_demand": "N",

    "selectable": "Y",

    "solution": "N"

}

 

All of these respond successfully, but when you try GET the attachment, it returns no binary. Furthermore, the attachments are not able to be opened from the webclient or smartclient.

GET https://{server}/odata/attachment(:attachment_id)/attachment

 

Is it even possible to handle this via the REST APIs? Or is the only way to first store the image somewhere accessible by the FSM Server, Store it on the FSM Server via REST, then delete the file on the initial server? Body in this case would look something like below.


Body:

{

    attachment@odata.mediaEditLink: https://{ServerAccessibleByFSMServer}/image.jpg,

    "attachment_name": "image.jpg",

    "file_extension": "jpg",

    "file_type": "image/jpeg",

    "stored": "Y",

    "active": "Y",

    "external_access": "N",

    "on_demand": "N",

    "selectable": "Y",

    "solution": "N"

}

Userlevel 1
Badge +3

Hi,

 

I experienced the same behavior. It seems we need to upload the attachment to the server/azure file shares first and then send the REST call with the path to the attachment. Is there a way to post the attachment as base64 string in the payload?

 

Thanks,

Dananjaya