Skip to main content
Question

Writing one field from GIS Feature Class to API Table PUT Request

  • 26 July 2024
  • 6 replies
  • 61 views

Hi everyone,

Curious if I could pick your brain on the workflow below.

I would like to just write the asset_id field values from the GIS feature class into the corresponding assetID field in the API table. I’d want to write the asset_id from the GIS FC to the assetID field in the API table only if the assetID doesn’t exist in the API table. They have different field names.

Curious where I would place the HttpCaller transformer with the PUT request in the workspace.

The GIS EGDB reader would be at the start of the workspace exposing the relevant fields. Once I rename the asset_id field from the GIS feature class to match that of assetID for the API table, what would I do? 

Could I hook up the output from an AttributeManager directly to an HTTPCaller without a Creator? 

 

6 replies

Userlevel 3
Badge +12

Hi @hawaiialex 

 

I would place the HTTP Caller transformer after the Attribute Manager. Yes, you can connect the output port from the Attribute Manager to the HTTP Caller without a creator. Just to confirm, does the API support updates?

Here are some tutorials that can help you set up your workspace using an HTTP caller.

Tutorial: Getting Started with APIs

If you need more clarification, could you provide some screenshots of your workspace or the workspace itself and I can take a closer look.

 

Crystal 

Userlevel 5
Badge +32

In this case the HTTPCaller is analogous to a writer/FeatureWriter.

Each feature will trigger a PUT request to the service. 

 

Badge +1

Thank you both @virtualcitymatt and @crystalatsafe! Note, I found that I need to process POST requests and not PUT as I previously indicated.

I’ve altered my workspace to place the HTTP Caller after the  Attribute Manager and took your advice to utilize the HTTP Caller similar to a writer.

The only issue I seem to be facing now is getting the format to write correctly to the API table.

Here is a sample of my workspace:

 

 

It seems to run correctly and when I check the API table it writes an odd value to the corresponding table rather than the unhighlighted values which is what I want (i.e. 410129) and not the reservoir-2024 line:

 

 

 

Note in the feature information tab, the assetId field seems to have a type of int16 which I changed from the default varchar(200) in the AttributeManager:

 

Is it an issue of how I formatted my HTTPCaller in the response handling or other paramter perhaps?

 

Thanks so much in advance again

Userlevel 5
Badge +32

Hmmm, I’m not familiar with the API so I can’t say 100%, however, looking at the HTTPCaller in the Query parameters it looks like you are adding a parameter with the value of the assestId and the value assetid.

Your URL would look like this form that request:
 

https://…../assetmanagement/assets/<someasset>?select=assetId&999999=999999

Note the 999999=999999 I took this from your inspector screenshot for the value of the assetId. 

In order to help further we would need to see some documentation about the specific API. 

Badge +1

@virtualcitymatt Thanks so much for the response!

Gotcha - I am super new to APIs. I would like the POST request to post the asset_id value from the GIS Feature Class into the corresponding assetId (JSON body) field which corresponds to the UNITID field name in the API table. 

With the current FME workspace, it does seem to write to the correct field as you saw in the screenshot, but just something strange.

If I just want to write the value of the asset_id to the UNITID (API Table field name) / assetId (JSON body) and not setting a specific asset number such as the &999999 value. I want the HTTPCaller to POST any value that is in the asset_id column of the GIS FC. So for example, if the asset_id value is 888888, I want it to post 888888 or if it is 999999, I want it to post 999999. 

I am guessing it would be either entering in another transformer to transform the value before being writtevia the HTTPCaller or a configuration parameter/setting in the HTTPCaller itself ?

Userlevel 3
Badge +12

Hi @hawaiialex 

If you are still experiencing this issue and if you are able to, please feel free to send over your workspace. I'm happy to take a closer look!

Also, can you share the API documentation?

I would confirm that the API you are using supports what you want to do and that you have the correct URL. I would also check to see if you have set up your HTTP Caller correctly and take another look at your Query String Parameters. Having a look at the HTTP Caller documentation may help with this.  

 

Please let me know if you need clarification about anything.

Crystal

Reply