HTTP Caller POST To Add Attachment to Cityworks Work Order
Im trying to work with the Cityworks API to create Work Orders using FME desktop.
I used the http caller to create the Work order and populate the necessary fields. However, my next challenge is to upload an attachment to the Work Order that comes from the attachment in the AGOL feature Layer created from Survey123. To do that I have used another HTTP caller set to POST with the URL
I know I have the Query string correct but I'm doing something wrong in the Multipart Upload section. Also, Do I need to use a token if I'm using a web connection for Authentication?
Page 1 / 1
I noticed that an attribute is used for the Value parameter in the Multi-Part upload. The POST request will fail if this attribute does not contain valid data. In this workflow, what is the value of the the arcgisonline_attachment{0} attribute?
In the following example, I am uploading a file from my local computer to a Cityworks attachment. The Value parameter contains a file path to that file. I've also set the MIME Type as "application/octet-stream" for a PDF file.
You might be interested in some of these suggestions and discussions about working with ArcGIS Online attachments:
I noticed that an attribute is used for the Value parameter in the Multi-Part upload. The POST request will fail if this attribute does not contain valid data. In this workflow, what is the value of the the arcgisonline_attachment{0} attribute?
In the following example, I am uploading a file from my local computer to a Cityworks attachment. The Value parameter contains a file path to that file. I've also set the MIME Type as "application/octet-stream" for a PDF file.
You might be interested in some of these suggestions and discussions about working with ArcGIS Online attachments:
Thanks for the input. I am able to attach files from my local drive. However, my goal is to take the attachments from an AGOL feature service and attach them to the Cityworks Work Order. the 'arcgisonline_attachment{0}.data' attribute holds the data from the attachment.
I'm just unclear on how to use it properly
Thanks for the input. I am able to attach files from my local drive. However, my goal is to take the attachments from an AGOL feature service and attach them to the Cityworks Work Order. the 'arcgisonline_attachment{0}.data' attribute holds the data from the attachment.
I'm just unclear on how to use it properly
I never succeeded in to get this to work. Instead I use a workaround with for example an AttributeFileWriter to save the data to a file and then send the file via multi-part upload. Maybe you can combine this with a TempFilePathCreator to write the file, send it and then automatically remove it after your workbench has finished running.
Thanks, that worked well. I'm still going to keep trying to find a way to directly attach the AGOL data file to the Cityworks Work Order when I have time. But for now, this is a great solution. Thanks again
Thanks, that worked well. I'm still going to keep trying to find a way to directly attach the AGOL data file to the Cityworks Work Order when I have time. But for now, this is a great solution. Thanks again
Hi do you have any follow up with how this went for you?
Hi do you have any follow up with how this went for you?
I never pursued finding a way to directly attach the AGOL data file to the Cityworks Work Order. Writing to a temporary on the FME server that is overwritten with each new attachment file works very well so there was no need to spend time finding another solution.
Hi do you have any follow up with how this went for you?
Makes a lot of sense. Appreciate you getting back to me so quick. Have a good one @bschabeniuk !
Thanks, that worked well. I'm still going to keep trying to find a way to directly attach the AGOL data file to the Cityworks Work Order when I have time. But for now, this is a great solution. Thanks again
The key item here is to review the documentation for the add attachment of Cityworks API or any API for that matter, and determine what is the required and supported formats . If its looking for a file, then there is no way to use the blob directly, which is similar to geodatabases. AGOL and Portal Add attachment API is similar to CityWorks - you can only add a file.
Hi @bschabeniuk, I’m trying to do something similar, just with adding an attachment to a service request rather than a work order. It’ll run in flow. The file is dynamic, since the workspace will be triggered by a survey response with an attachment. So far I’ve been able to write the file to a folder in Flow. I’m not sure what the next steps are though, how to reference this file in the http caller? I had used the path reader to supply the value, but that didn’t work.
Hi @bschabeniuk, I’m trying to do something similar, just with adding an attachment to a service request rather than a work order. It’ll run in flow. The file is dynamic, since the workspace will be triggered by a survey response with an attachment. So far I’ve been able to write the file to a folder in Flow. I’m not sure what the next steps are though, how to reference this file in the http caller? I had used the path reader to supply the value, but that didn’t work.
Hi @a_jose . Not sure if you were able to find a way to do this. I recently built something similar and found a work around. I used the URL of the attachment from Survey123 and added it to the Comments section of the service request by using the ServiceRequestCreator transformer. It couldn’t be added to the Attachments section but being able to add the clickable attachment URL to the Comments section was great. If there was no attachment I added a comment that said, “No Survey123 Attachment”. To build the URL of the Survey123 AGO attachment first, I used the StringConcatenator transformer. In that StringConcatenator transformer the String parts were: First a Constant which will be the beginning static part of the URL, the next string type will be an Attribute Value of the objectid. The third line will be another constant: /attachments/ and the fourth line will be another Attribute Value of argisonline_attachment{0}.id. These argisonline fields were first exposed in the Reader. This newly created attachment URL can then be input into the ServiceRequestCreator transformer (additional request parameters) section.
Before moving to Comments, I blanked out any partial URLs that were created in the StringConcatenator transformer that didn’t have an attachment name. If the attachment name was missing then I ignored any partial URLs that were created for those records with no attachment.
To get the attachment name I used the ListExploder transformer after the StringConcatenator. The list attribute to explode in that transformer is: arcgisonline_attachment{}. That will get you the attachment names.
This below is from the ServiceRequestCreator transformer, Additional Request Parameters section. It’s moving the AttachmentURL to the Comments section of the Service Request.