Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By : Donald Eric Pimpler, Eric Pimpler
Book Image

Programming ArcGIS with Python Cookbook, Second Edition

By: Donald Eric Pimpler, Eric Pimpler

Overview of this book

Table of Contents (22 chapters)
Programming ArcGIS with Python Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Making HTTP requests and parsing the response with Python


There are a number of Python modules that you can use to make REST requests. There are really too many! Modules include urllib2, httplib2, pycurl, and requests. requests is definitely the best of the bunch in my opinion. It is cleaner and easier to use for repeated interaction with RESTful APIs. Once you've made the request, you can then parse the JSON response with the Python json module. In this recipe, you will learn how to do this.

Getting ready

The Python requests module can be used to submit requests to an ArcGIS Server resource and process the returned response. Follow these steps to learn the basic steps involved in submitting requests and processing the response using the requests module:

How to do it…

Before we get started, make sure that you have downloaded and installed the requests module, using pip. If you haven't already done so, I have provided the following instructions to install both pip and the requests module:

Note...