# 501 error for httpPost

**URL:** <https://forum.inductiveautomation.com/t/501-error-for-httppost/75924>\
**Category:** Ignition\
**Created:** [July 5, 2023, 9:49am UTC](https://forum.inductiveautomation.com/t/501-error-for-httppost/75924 "2023-07-05T09:49:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Learner\_Ignition](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Learner\_Ignition](https://forum.inductiveautomation.com/u/Learner_Ignition)\
**Post date:** [July 5, 2023, 9:49am UTC](https://forum.inductiveautomation.com/t/501-error-for-httppost/75924/1 "2023-07-05T09:49:19Z")

</div>

Hi,  
As a learner  
I am trying to implement [httpPost Example](https://docs.inductiveautomation.com/display/DOC81/httpPost+Example)  
However after copying pasting and doing some modification also I am getting

 ![Error](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/c/dcd64430d93a5fca24064a35ba40a959aae6204a.jpeg)  
501 error.

I am trying to send the Json data by after clicking on button and then in Webdev trying to get data into variable.

 ![script](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/8/08c65e339e13773771576bfc53bc1e1f96ae7643.jpeg)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 5, 2023, 12:14pm UTC](https://forum.inductiveautomation.com/t/501-error-for-httppost/75924/2 "2023-07-05T12:14:46Z")

</div>

That generally means your WebDev script threw an exception. Showing that in the web result would be insecure. Look in your gateway logs.

Or, perhaps, add logging and `try:` - `except:` blocks in your WebDev jython.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 5, 2023, 12:25pm UTC](https://forum.inductiveautomation.com/t/501-error-for-httppost/75924/3 "2023-07-05T12:25:31Z")

</div>

show us the webdev post code

in web 501 generaly means it doesnt exists ( Test1 is a wrong name/method?), idk if igntions throws this for something else too tho

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 5, 2023, 12:25pm UTC](https://forum.inductiveautomation.com/t/501-error-for-httppost/75924/4 "2023-07-05T12:25:54Z")

</div>

What's in your `Test1` webdev script exactly ?

Did you make sure to set its method to `POST` ?

---

<div class="post-metadata">

**Author:** ![Learner\_Ignition](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Learner\_Ignition](https://forum.inductiveautomation.com/u/Learner_Ignition)\
**Post date:** [July 6, 2023, 3:32am UTC](https://forum.inductiveautomation.com/t/501-error-for-httppost/75924/5 "2023-07-06T03:32:19Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/e/1e8775f3ae74dc9fccbc0753362ef5dec49c8ce1.png)  
I have attached Test1 Webdev script

---

<div class="post-metadata">

**Author:** ![Daniel\_Arekion](https://avatars.discourse-cdn.com/v4/letter/d/41988e/32.png) [@Daniel\_Arekion](https://forum.inductiveautomation.com/u/Daniel_Arekion)\
**Post date:** [December 6, 2023, 6:54am UTC](https://forum.inductiveautomation.com/t/501-error-for-httppost/75924/6 "2023-12-06T06:54:29Z")

</div>

Getting same error here. Did you manage to solve it?

---

<div class="post-metadata">

**Author:** ![Hayden\_Watson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hayden_watson/32/48792_2.png) [@Hayden\_Watson](https://forum.inductiveautomation.com/u/Hayden_Watson)\
**Post date:** [December 6, 2023, 8:12am UTC](https://forum.inductiveautomation.com/t/501-error-for-httppost/75924/7 "2023-12-06T08:12:29Z")

</div>

Normally an exception in your code, if I had to guess in the above, the `request["postData"]` was the issue as I think the correct dict key is `request["data"]`.

---

<div class="post-metadata">

**Author:** ![Learner\_Ignition](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Learner\_Ignition](https://forum.inductiveautomation.com/u/Learner_Ignition)\
**Post date:** [December 6, 2023, 9:01am UTC](https://forum.inductiveautomation.com/t/501-error-for-httppost/75924/8 "2023-12-06T09:01:37Z")

</div>

This worked for me.

```auto
def doPost(request, session):

	data = request["postData"]
	response_data = data[0][0]["val"]
	system.tag.writeBlocking(["[Test_Tag_Provider]Test/Recipe1"], [response_data])
	
	response_json = system.util.jsonEncode(response_data)
	
	return {"response": response_json, "contentType": "application/json"}

```
