# \[BUG? \]Code in Webdev python resource won't execute (redirect\_policy in system.net.httpClient DOES NOT defaults to "NORMAL")

**URL:** <https://forum.inductiveautomation.com/t/bug-code-in-webdev-python-resource-wont-execute-redirect-policy-in-system-net-httpclient-does-not-defaults-to-normal/47257>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [May 29, 2021, 10:15pm UTC](https://forum.inductiveautomation.com/t/bug-code-in-webdev-python-resource-wont-execute-redirect-policy-in-system-net-httpclient-does-not-defaults-to-normal/47257 "2021-05-29T22:15:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [May 29, 2021, 10:15pm UTC](https://forum.inductiveautomation.com/t/bug-code-in-webdev-python-resource-wont-execute-redirect-policy-in-system-net-httpclient-does-not-defaults-to-normal/47257/1 "2021-05-29T22:15:22Z")

</div>

I’m trying to get simple httpGet and httpPost to get working, but …  
I have this simple python resource in Webdev module called readTags.  
And in Script console this code:

 ![Screenshot_3](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/0/006f4c11799710bd98b8a3d73e05544ed0cb092b.png)  
The code in the Webdev module never gets executed.  
I was spending last 8 hours going through every forum post about webdev and httpPost and Get and I can’t figure it out…

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [May 29, 2021, 11:21pm UTC](https://forum.inductiveautomation.com/t/bug-code-in-webdev-python-resource-wont-execute-redirect-policy-in-system-net-httpclient-does-not-defaults-to-normal/47257/2 "2021-05-29T23:21:13Z")

</div>

Your web dev script is not returning anything. Read the top part, you need to return a dictionary with the appropriate key and response to the request.

Also your logger will log to the gateway logs if you are trying to look for errors or loggers you need to be on the gateway.

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [May 30, 2021, 5:13am UTC](https://forum.inductiveautomation.com/t/bug-code-in-webdev-python-resource-wont-execute-redirect-policy-in-system-net-httpclient-does-not-defaults-to-normal/47257/3 "2021-05-30T05:13:20Z")

</div>

Yes, I know that my Webdev script is not **returning** anything.  
The problem is that it doesn’t get **executed** at all.  
It won’t print in wrapper.log and in gateway logs and also there are no ‘myLogger’ entries…

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [May 30, 2021, 8:41am UTC](https://forum.inductiveautomation.com/t/bug-code-in-webdev-python-resource-wont-execute-redirect-policy-in-system-net-httpclient-does-not-defaults-to-normal/47257/4 "2021-05-30T08:41:57Z")

</div>

I managed to get httpPost working… but client.post or client.get or client.put is still not…  
I’m really confused…

 ![Screenshot_4](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/b/fb6df51dbabed55145a991f0665aa59d5b3b1060.png)

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [May 30, 2021, 10:59am UTC](https://forum.inductiveautomation.com/t/bug-code-in-webdev-python-resource-wont-execute-redirect-policy-in-system-net-httpclient-does-not-defaults-to-normal/47257/5 "2021-05-30T10:59:07Z")

</div>

How are you testing it?

Sorry just saw.

Can you test with postman and see if that makes a difference?

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [May 30, 2021, 11:22am UTC](https://forum.inductiveautomation.com/t/bug-code-in-webdev-python-resource-wont-execute-redirect-policy-in-system-net-httpclient-does-not-defaults-to-normal/47257/6 "2021-05-30T11:22:17Z")

</div>

Finally, it’s working.  
I had to put `redirect_policy = "NORMAL"` into the

```auto
client = system.net.httpClient(redirect_policy = "NORMAL")

```

 ![Screenshot_9](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/3/53e529853a5e777e9a62312317dfad3a7447bf22.png)  
If the manual were OK, then I wouldn’t spend two days on this…  
 ![Screenshot_10](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/5/25b6e5b73fbc58c53b2dd0fb9e77558f8df071b3.png)

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [May 30, 2021, 11:27am UTC](https://forum.inductiveautomation.com/t/bug-code-in-webdev-python-resource-wont-execute-redirect-policy-in-system-net-httpclient-does-not-defaults-to-normal/47257/7 "2021-05-30T11:27:37Z")

</div>

You do not need the /main in the url. That changed in ignition 8. That’s why your getting a http 307 redirect response code.

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [May 30, 2021, 11:34am UTC](https://forum.inductiveautomation.com/t/bug-code-in-webdev-python-resource-wont-execute-redirect-policy-in-system-net-httpclient-does-not-defaults-to-normal/47257/8 "2021-05-30T11:34:15Z")

</div>

Vau! 🙄  
How the f\*\*k should I know that?

---

<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:** [May 30, 2021, 1:26pm UTC](https://forum.inductiveautomation.com/t/bug-code-in-webdev-python-resource-wont-execute-redirect-policy-in-system-net-httpclient-does-not-defaults-to-normal/47257/9 "2021-05-30T13:26:01Z")

</div>

The URLs in the WebDev docs are all accurate and do not include /main in the URL. I guess if you started in 7.9 and then upgraded this corner case might get you.

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [May 30, 2021, 3:12pm UTC](https://forum.inductiveautomation.com/t/bug-code-in-webdev-python-resource-wont-execute-redirect-policy-in-system-net-httpclient-does-not-defaults-to-normal/47257/10 "2021-05-30T15:12:33Z")

</div>

> [@Kevin.Herron](#):
>
> I guess if you started in 7.9 and then upgraded this corner case might get you.

That must be it.  
Regardless, my point about redirect\_policy still stands:  
If you have /home in your URL, and create `system.net.httpClient()` without `redirect_policy="NORMAL"` then it won't work.  
So, it doesn't default to "NORMAL"... ?

---

<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:** [May 30, 2021, 4:49pm UTC](https://forum.inductiveautomation.com/t/bug-code-in-webdev-python-resource-wont-execute-redirect-policy-in-system-net-httpclient-does-not-defaults-to-normal/47257/11 "2021-05-30T16:49:31Z")

</div>

The default redirect policy for Java 11’s HttpClient is [never](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.Builder.html#followRedirects(java.net.http.HttpClient.Redirect)), which is the safest default policy.

The reason I call this a corner case is aside from the removal of /main and the redirect that replaced it, most WebDev endpoints aren’t even consumed by Ignition’s own HTTP client, but rather they are consumed by external entities.

edit: Oh I see, our docs say it defaults to “normal” though… Do you have HTTPS enabled? “Normal” means “follow redirects unless it’s an HTTPS → HTTP redirect”… maybe that has something to do with it.

edit2: I think our docs are just wrong. Sorry that caused you some grief.
