Esri / ArcREST

python package for REST API (AGS, AGOL, webmap JSON, etc..)
Apache License 2.0
192 stars 155 forks source link

generateKML for map service - urllib2.HTTPError: HTTP Error 400: Bad Request #198

Closed AlexArcPy closed 8 years ago

AlexArcPy commented 8 years ago

I am on ArcREST Version 3.5.3 Release.

When trying to generate a KML file, an error is returned: urllib2.HTTPError: HTTP Error 400: Bad Request

The code breaks at this line:

resp = opener.open(fullurl=format_url)

In the file arcrest/web/_base.py

format_url has the value of

'http://localhost:6080/arcgis/rest/services/SampleWorldCities/MapServer/generateKml?docName=SampleKML&layers=1&layerOptions=composite&f=json?token=80bbvISXd4eTJXc2Whn4MmlSUvFZPy4m6KaC0pEx0KdJHtABCq_rDWG1cRa79YxH'

before it's being executed.

If navigating to the URL that is built in the code in the browser, the .kmz is generated as expected.

http://localhost:6080/arcgis/rest/services/SampleWorldCities/MapServer/generateKml?docName=SampleKML&layers=1&layerOptions=composite&f=json
achapkowski commented 8 years ago

What version of server are you using?

AlexArcPy commented 8 years ago

Sorry, forgot to mention. I am on 10.3.1.

AlexArcPy commented 8 years ago

Have tested on 10.4 machine; same error.

achapkowski commented 8 years ago

@AlexArcPy - Issue should be resolved.

AlexArcPy commented 8 years ago

@achapkowski , thanks a lot for helping with that. Unfortunately, it's complaining about the import on the line you've added: from six.moves.urllib_parse import urlencode

ImportError: No module named six.moves.urllib_parse

The six is not installed in the site packages. Do I need to install it manually via pip? I do see it here at C:\Python27\ArcGIS10.3\Lib\site-packages\arcresthelper\packages but it seems it cannot be imported as is...

AlexArcPy commented 8 years ago

I've got the latest code in the repo and commented out the line from six.moves.urllib_parse import urlencode and the kmz is generated now.

achapkowski commented 8 years ago

I'll fix the import, it needs to grab six from the ..package submodule. I thought I committed the change.

?