Skip to main content

Hello. I am trying to use the Esri ArcGIS Portal Feature Service Reader/Writer in FME Desktop 2018.1 and am getting a Python KeyError exception when trying to authenticate the login. I am using "Generate Token" as the authentication type, and trying to connect to an instance of Portal for ArcGIS (10.6.1).

Here's the relevant excerpt from the log:

|INFORM|ArcGIS Portal Feature Service Writer: Logging into 'Ohost url]' as user 'eusername]'
|ERROR |Python Exception <KeyError>: u'token'
|ERROR |A fatal error has occurred. Check the logfile above for details
|ERROR |... Last line repeated 2 times ...

The strange thing is that this workspace ran successfully a few days ago.

Any input would be appreciated. Thanks!

Hi @neuwerld, are you still having this issue? If you are, can you share the full log with us so we can help look into it? It's strange that it stopped working. Did anything on the ArcGIS portal instance change?
Hi @neuwerld,

 

Are you able to login with your credentials using a web browser just fine? The error suggests that perhaps no token was returned during the authentication process.

 

Best,

 

Nathan

 


 

@XiaomengAtSafe @NathanAtSafe Thank you for the comments. I am still having the issue, but Nathan's comment gave me the idea to try to log in using a web browser. I found that I cannot log in to the particular host URL I used. I used the format https://server.domain.com:7443/arcgis, because that was the only URL that didn't return the "does not appear to be an ArcGIS Portal Instance" error. I can log in to https://server.domain.com/portal (and that seems like it should be the host used in the Portal Feature Service reader/writer) but I get that "does not appear to be an ArcGIS Portal Instance" error when using that URL. I'm not sure how the workspace worked a few times previously, but based on the fact that I can't login at the URL I was using I think that was probably the source of the error. I still don't know why none of the URLs I've tried are recognized as valid Portal Instances, but I have come up with a workaround anyway. I am now using a PythonCaller and ArcPy.

 

@XiaomengAtSafe @NathanAtSafe Thank you for the comments. I am still having the issue, but Nathan's comment gave me the idea to try to log in using a web browser. I found that I cannot log in to the particular host URL I used. I used the format https://server.domain.com:7443/arcgis, because that was the only URL that didn't return the "does not appear to be an ArcGIS Portal Instance" error. I can log in to https://server.domain.com/portal (and that seems like it should be the host used in the Portal Feature Service reader/writer) but I get that "does not appear to be an ArcGIS Portal Instance" error when using that URL. I'm not sure how the workspace worked a few times previously, but based on the fact that I can't login at the URL I was using I think that was probably the source of the error. I still don't know why none of the URLs I've tried are recognized as valid Portal Instances, but I have come up with a workaround anyway. I am now using a PythonCaller and ArcPy.

Hi @neuwerld

Having the same issue with no changes to our Portal instances. Your workaround using Python caller is successful - great, that's good to hear. Would you share back to the community (this post) your approach in the caller? I'm newer to Python and custom coding solutions so any direction or samples would be much appreciated.

Thanks - Suz


Hi @neuwerld

Having the same issue with no changes to our Portal instances. Your workaround using Python caller is successful - great, that's good to hear. Would you share back to the community (this post) your approach in the caller? I'm newer to Python and custom coding solutions so any direction or samples would be much appreciated.

Thanks - Suz

Hello @geobaehr,

I used a PythonCaller to publish directly to an ArcGIS Server, avoiding the need to log in to a Portal instance. I haven't gone beyond testing/proof of concept with this (it hasn't been used in a production system) because I ended up going with a different workflow, but I've published a number of map and feature services using a couple FME Workspaces I created. My general approach was to translate Python code from ArcGIS Toolbox tools I created into the script of FME PythonCallers. My FME Workspaces consist of a Creator (which creates a null geometry object) linked to a PythonCaller.

The Python script I wrote is very similar to the code provided here, with the main difference being that I wanted to get the publishing parameters from the user rather than have them hard-coded in.

For translating from an ArcGIS Toolbox tool to FME, the changes I made to the code were:

  • The format of user parameters
    • For example:
      • Getting a value from the user in a toolbox tool: input_mxd = arcpy.GetParameterAsText(0)
      • Equivalent statement in the PythonCaller script box: input_mxd = FME_MacroValues['<published parameter name>']
  • Logging statements
    • Use "print" statements or a logger object rather than arcpy.AddMessage()

The code above refers to publishing a map service. Publishing a feature service is more complicated because you have to modify the XML of the service definition draft to enable feature access on the service. Here's a discussion about this, including some code that I referenced when writing my script (I also compared the XML of a feature service to that of a map service to see what the differences are—there are only few properties you have to change).

Here's more documentation about using Python and ArcPy in FME:

https://knowledge.safe.com/articles/706/python-and-fme-basics.html

https://knowledge.safe.com/articles/29799/importing-arcpy-troubleshooting-ideas.html

I can provide some code if you're interested (it's just hard to fit it in this section nicely, given how narrow it is).

 

That said, at this point if I were to use FME to publish to an ArcGIS Server or Portal/AGOL instance, I would look into using the ArcGIS API for Python. I've found it to be an easy way to access Server and Portal/AGOL instances using custom script tools in ArcGIS Pro.


Reply