# API request in rhino python

**URL:** <https://discourse.mcneel.com/t/api-request-in-rhino-python/47945>\
**Category:** Scripting\
**Tags:** mac, python\
**Created:** [October 4, 2017, 10:10am UTC](https://discourse.mcneel.com/t/api-request-in-rhino-python/47945 "2017-10-04T10:10:23Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Joost\_Barendregt](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/joost_barendregt/32/52559_2.png) [@Joost\_Barendregt](https://discourse.mcneel.com/u/Joost_Barendregt)\
**Post date:** [October 11, 2017, 1:09pm UTC](https://discourse.mcneel.com/t/api-request-in-rhino-python/47945/6 "2017-10-11T13:09:01Z")

</div>

urllib was not enough to make the request I wanted, but urllib2 helped out:

```
def requestAPIData(url, jsonRequestData):
    request = urllib2.Request(url)
    request.add_data(json.dumps(jsonRequestData))
    request.add_header("Content-type", "application/json")
    request.add_header("Accept", "application/json")

    r = urllib2.urlopen(request)
    geometryJson = json.load(r)
    return geometryJson

```

thanks for the help!

---

_[View the full topic](https://discourse.mcneel.com/t/api-request-in-rhino-python/47945)._
