# Using request\["data"\] in doGet() python resource in Web Dev

**URL:** <https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992>\
**Category:** Ignition\
**Created:** [February 10, 2022, 6:01pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992 "2022-02-10T18:01:40Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![user66](https://avatars.discourse-cdn.com/v4/letter/u/b487fb/32.png) [@user66](https://forum.inductiveautomation.com/u/user66)\
**Post date:** [February 10, 2022, 6:01pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/1 "2022-02-10T18:01:40Z")

</div>

I’m trying to receive a list or dictionary using _request[“data”]_ in doGet() python resource but not sure how to send data to the resource

---

<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:** [February 10, 2022, 6:19pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/2 "2022-02-10T18:19:52Z")

</div>

GET requests do not (cannot) have a body; you need to use URL parameters (and thus, `request["params"]`) to pass data to a GET endpoint.

Query parameters go into the URL directly; start query params with a `?`, separate them with `&` and, if necessary, URL-encode any non-basic-ASCII values:  
`system/webdev/test/asdf?param=1&param2=2&param=2`

---

<div class="post-metadata">

**Author:** ![user66](https://avatars.discourse-cdn.com/v4/letter/u/b487fb/32.png) [@user66](https://forum.inductiveautomation.com/u/user66)\
**Post date:** [February 11, 2022, 12:58pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/3 "2022-02-11T12:58:28Z")

</div>

can POST request have a body?  
how can we use request[“data”]?

---

<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:** [February 11, 2022, 1:30pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/4 "2022-02-11T13:30:06Z")

</div>

Yes, POST requests accept an incoming body. There are [examples here on the forum](https://forum.inductiveautomation.com/search?q=webdev%20doPost%20request).

---

<div class="post-metadata">

**Author:** ![Rui\_Gao](https://avatars.discourse-cdn.com/v4/letter/r/b5e925/32.png) [@Rui\_Gao](https://forum.inductiveautomation.com/u/Rui_Gao)\
**Post date:** [May 6, 2023, 8:47am UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/5 "2023-05-06T08:47:13Z")

</div>

使用script library 的第三方脚本可以事项 DoGet 传递Body 值

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 6, 2023, 10:24am UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/6 "2023-05-06T10:24:39Z")

</div>

> [@Rui\_Gao](#):
>
> 的第三方脚本可以事项 DoGet 传递Body 值

Is this a question?

---

<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:** [May 6, 2023, 1:16pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/7 "2023-05-06T13:16:34Z")

</div>

Via [Google Translate](https://translate.google.com/)

> [@Rui\_Gao](#):
>
> Third-party scripts using the script library can pass the Body value through DoGet

The `doGet()` method in WebDev can certainly pass the body content to a script in that project's script library. I'm not sure if that is precisely what you meant.

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [May 8, 2023, 7:58pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/8 "2023-05-08T19:58:20Z")

</div>

Are you sure about this? I may be misunderstanding you, but I just set up a `doGet` webdev endpoint and pass in `request.data` directly that I use as parameters to a named query and it works - did you mean something else?

**Edit: Snip of my setup**

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/b/2ba099e0dc5d4c6ac941556385c44472b079ccd5.png)

---

<div class="post-metadata">

**Author:** ![Paramesh\_Sekhar](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Paramesh\_Sekhar](https://forum.inductiveautomation.com/u/Paramesh_Sekhar)\
**Post date:** [March 14, 2024, 4:39pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/9 "2024-03-14T16:39:41Z")

</div>

My query data result is in json format using 'FOR JSON PATH' clause. When returning this value from Web Dev - doGet method, it is not showing in the same format. It is splitting the data into multiple blocks. How do I send the query result in doGet return statement?

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [March 14, 2024, 4:42pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/10 "2024-03-14T16:42:21Z")

</div>

Can you explain or show what you mean by multiple blocks?

---

<div class="post-metadata">

**Author:** ![Paramesh\_Sekhar](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Paramesh\_Sekhar](https://forum.inductiveautomation.com/u/Paramesh_Sekhar)\
**Post date:** [March 14, 2024, 4:50pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/11 "2024-03-14T16:50:52Z")

</div>

Thanks for the response, the blocks are like this:  
[  
[  
25 rows added here  
],  
[  
25 rows added here  
],  
[  
25 rows added here  
]  
]

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [March 14, 2024, 4:54pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/12 "2024-03-14T16:54:20Z")

</div>

Can you show the output of the named query outside of the doGet call? There's nothing in the endpoint (afaik) or the `decode` function that would break up the response like that.

Are you running the query with the same parameters when you're testing outside of WebDev?

---

<div class="post-metadata">

**Author:** ![Paramesh\_Sekhar](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Paramesh\_Sekhar](https://forum.inductiveautomation.com/u/Paramesh_Sekhar)\
**Post date:** [March 14, 2024, 5:04pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/13 "2024-03-14T17:04:33Z")

</div>

The query is just a simple select statement and the result is like this with more than 100 locations,  
{"Data":[{"Location":"01","ALocation":4,"Type":"M"},{"Location":"02","ALocation":105,"Type":"M"}]}

SELECT Location, ALocation, Type  
FROM table1  
FOR JSON PATH, ROOT ('Data');

def doGet(request, session):  
value = system.dataset.toPyDataSet(system.db.runNamedQuery("query1"))   
jsonString = system.util.jsonEncode(value)  
return {'json':value}  
# return {'json':jsonString} -- returns the same result when launched

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [March 14, 2024, 5:48pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/14 "2024-03-14T17:48:25Z")

</div>

If I remember SQL Server json encoding correctly, you should just be able to do this:

```python
def doGet(request, session):
    locations = system.db.runNamedQuery("query1")
    return {"json": locations}

```

since `locations` is already a JSON string. You would need to `jsonDecode` if you wanted to return a `dict` instead of JSON. Try that out and see how it goes.

Also, I feel like you might find encode/decode errors in the logs if the parameters are in the correct format, I would check those.

---

<div class="post-metadata">

**Author:** ![Paramesh\_Sekhar](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Paramesh\_Sekhar](https://forum.inductiveautomation.com/u/Paramesh_Sekhar)\
**Post date:** [March 14, 2024, 6:51pm UTC](https://forum.inductiveautomation.com/t/using-request-data-in-doget-python-resource-in-web-dev/55992/15 "2024-03-14T18:51:53Z")

</div>

Found the issue is related to the browser where I was checking the results. Chrome shows correctly, and Edge splitting the data. Thank you for responding to my request!
