# Accessing web services from Ignition

**URL:** <https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749>\
**Category:** Ignition\
**Created:** [January 26, 2013, 6:31pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749 "2013-01-26T18:31:09Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![hari2012](https://avatars.discourse-cdn.com/v4/letter/h/51bf81/32.png) [@hari2012](https://forum.inductiveautomation.com/u/hari2012)\
**Post date:** [January 26, 2013, 6:31pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/1 "2013-01-26T18:31:09Z")

</div>

I have a project where I need to retrieve data using web services. Is there any tutorial/sample code available on how to configure Ignition to call web services?  
Thanks

---

<div class="post-metadata">

**Author:** ![tailfire](https://avatars.discourse-cdn.com/v4/letter/t/b5a626/32.png) [@tailfire](https://forum.inductiveautomation.com/u/tailfire)\
**Post date:** [January 26, 2013, 7:01pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/2 "2013-01-26T19:01:49Z")

</div>

[inductiveautomation.com/supp … /ignition/](http://www.inductiveautomation.com/support/usermanuals/ignition/)  
There is a new section on web services. Also they are not all the same.  
A service that uses true wsdl dialog is different than an xml server

Also check out  
[w3schools.com/webservices/default.asp](http://www.w3schools.com/webservices/default.asp)

This  
[fedorahosted.org/suds/](https://fedorahosted.org/suds/) is the native libraries in ignition

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [January 30, 2013, 6:04pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/3 "2013-01-30T18:04:44Z")

</div>

Here are direct links to the sections in the user manual:  
[inductiveautomation.com/supp ... uments.htm](http://www.inductiveautomation.com/support/usermanuals/ignition/index.html?overview__simple_arguments.htm)  
[inductiveautomation.com/supp ... uments.htm](http://www.inductiveautomation.com/support/usermanuals/ignition/index.html?complex_arguments.htm)  
[inductiveautomation.com/supp ... esults.htm](http://www.inductiveautomation.com/support/usermanuals/ignition/index.html?parsing_xml_results.htm)

Also, the link that @tailfire posted to the SUDS documentation is very helpful.

---

<div class="post-metadata">

**Author:** ![hari2012](https://avatars.discourse-cdn.com/v4/letter/h/51bf81/32.png) [@hari2012](https://forum.inductiveautomation.com/u/hari2012)\
**Post date:** [February 14, 2013, 9:06pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/4 "2013-02-14T21:06:15Z")

</div>

Thanks for the info  
The webservice that I would like to interface with from Ignition uses REST/JSon. I am not too familar with this. I would like to know if we can use Ignition to retrieve data from these type of web services.

---

<div class="post-metadata">

**Author:** ![Michael.Stofan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.stofan/32/3342_2.png) [@Michael.Stofan](https://forum.inductiveautomation.com/u/Michael.Stofan)\
**Post date:** [February 15, 2013, 12:10am UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/5 "2013-02-15T00:10:10Z")

</div>

The JSON library for python is external, which mean that for now it can’t be used from within Ignition. You’ll be able to get the JSON response back from the server’s RESTful API, but you won’t really be able to do anything useful with it.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [August 14, 2013, 5:30pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/6 "2013-08-14T17:30:34Z")

</div>

Ignition now has built-in JSON parsing functions that convert JSON into Python data structures or parse Python data structures to JSON.

system.util.jsonDecode(jsonString)  
system.util.jsonEncode(pyObj)

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [August 14, 2013, 5:52pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/7 "2013-08-14T17:52:30Z")

</div>

You can use system.net.httpGet and system.net.httpPost to use RESTful web services.

---

<div class="post-metadata">

**Author:** ![Brian.Boothe](https://avatars.discourse-cdn.com/v4/letter/b/c6cbf5/32.png) [@Brian.Boothe](https://forum.inductiveautomation.com/u/Brian.Boothe)\
**Post date:** [November 6, 2020, 3:34pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/9 "2020-11-06T15:34:29Z")

</div>

yes is it can use REST/JSON we are doing it this way as of now

---

<div class="post-metadata">

**Author:** ![noveel.azhar](https://avatars.discourse-cdn.com/v4/letter/n/b19c9b/32.png) [@noveel.azhar](https://forum.inductiveautomation.com/u/noveel.azhar)\
**Post date:** [March 2, 2021, 10:25pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/10 "2021-03-02T22:25:10Z")

</div>

I also need to use webservices. I see is Webservices module in python but I was unable to find any documentation on how to use it.  
Thanks for your help

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 2, 2021, 11:50pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/11 "2021-03-02T23:50:59Z")

</div>

Since _2013_, things have improved a lot in the core Ignition product. For all REST (and, really, most HTTP related calls) I’d recommend [`system.net.httpClient`](https://docs.inductiveautomation.com/display/DOC81/system.net.httpClient).

---

<div class="post-metadata">

**Author:** ![noveel.azhar](https://avatars.discourse-cdn.com/v4/letter/n/b19c9b/32.png) [@noveel.azhar](https://forum.inductiveautomation.com/u/noveel.azhar)\
**Post date:** [March 3, 2021, 1:40pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/12 "2021-03-03T13:40:34Z")

</div>

> [@adamaustin](#):
>
> system.net.httpPost

Thanks. I tried a simple script on sript console and I am getting error  
**Script**  
url= '[http://myurl](http://myurl)'  
client = system.net.httpClient()  
response = client.post(url, params = {"DeviceId": "WPISC2001","CardId": "00.00.00.00.44.C0.56.51"})

**Error**  
Traceback (most recent call last):  
File "", line 2, in   
AttributeError: 'com.inductiveautomation.ignition.designer.gui.tool' object has no attribute 'httpClient'

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 3, 2021, 1:42pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/13 "2021-03-03T13:42:29Z")

</div>

What version of Ignition are you using?

---

<div class="post-metadata">

**Author:** ![noveel.azhar](https://avatars.discourse-cdn.com/v4/letter/n/b19c9b/32.png) [@noveel.azhar](https://forum.inductiveautomation.com/u/noveel.azhar)\
**Post date:** [March 3, 2021, 1:57pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/14 "2021-03-03T13:57:20Z")

</div>

I am using 7.9.12  
Thanks

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 3, 2021, 1:58pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/15 "2021-03-03T13:58:20Z")

</div>

`system.net.httpClient` wasn’t available until something like 8.0.6.

You’ll have to stick to `system.net.httpGet` and `system.net.httpPost`.

---

<div class="post-metadata">

**Author:** ![noveel.azhar](https://avatars.discourse-cdn.com/v4/letter/n/b19c9b/32.png) [@noveel.azhar](https://forum.inductiveautomation.com/u/noveel.azhar)\
**Post date:** [March 4, 2021, 2:28pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/16 "2021-03-04T14:28:19Z")

</div>

If I use system.net.httpClient is get error code 500 from server. I tried postman and SOAP to confirm the hearder and te url endpoint are working fine. Here is te script I am testing on script console  
Script:  
url= “my url”  
devi =“WPISC2001”  
card = “00.00.00.00.44.C0.56.51”  
header = {“DeviceId”:devi,“CardId”:card}  
print(header)

response = system.net.httpPost(url,‘application/json; charset=utf-8’, headerValues=header)  
print(response)

Error:  
File “”, line 7, in   
IOError: Server returned HTTP response code: 500 for URL: “my url”

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 4, 2021, 5:05pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/17 "2021-03-04T17:05:55Z")

</div>

You’re sending `DeviceId` and `CardId` as header values, not the actual data payload - is that intentional? If so, it’s one of the weirdest web APIs I’ve ever heard of. I would expect you to have to do something like this:

```auto
url= 'my url'
devi = 'WPISC2001'
card = '00.00.00.00.44.C0.56.51'
payload = {'DeviceId': devi, 'CardId': card}
print(payload)

response = system.net.httpPost(url, contentType='application/json; charset=utf-8', postData=system.util.jsonEncode(payload))
print(response)

```

Or, better, with `httpClient`:

```auto
url= 'my url'
devi = 'WPISC2001'
card = '00.00.00.00.44.C0.56.51'
payload = {'DeviceId': devi, 'CardId': card}
print(payload)

response = system.net.httpClient().post(url, payload)
print(response)

```

Which will automatically encode the payload as JSON and set the content-type header for you.

---

<div class="post-metadata">

**Author:** ![noveel.azhar](https://avatars.discourse-cdn.com/v4/letter/n/b19c9b/32.png) [@noveel.azhar](https://forum.inductiveautomation.com/u/noveel.azhar)\
**Post date:** [March 4, 2021, 5:09pm UTC](https://forum.inductiveautomation.com/t/accessing-web-services-from-ignition/5749/18 "2021-03-04T17:09:44Z")

</div>

Thanks a lot PGriffith and everyone. No it was not intentional I made a mistake. I tried your way and it is working now.  
Really appreciate your help

Regards  
Noveel
