# Req Body auto change issue

**URL:** <https://discuss.blues.com/t/req-body-auto-change-issue/1011>\
**Category:** Tools & SDKs\
**Tags:** python\
**Created:** [October 1, 2022, 4:21pm UTC](https://discuss.blues.com/t/req-body-auto-change-issue/1011 "2022-10-01T16:21:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pradeep](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/pradeep/32/479_2.png) [@Pradeep](https://discuss.blues.com/u/Pradeep)\
**Post date:** [October 1, 2022, 4:21pm UTC](https://discuss.blues.com/t/req-body-auto-change-issue/1011/1 "2022-10-01T16:21:23Z")

</div>

Hi All,

I’m trying to read the ESP32 data in the form of JSON with pyserial and revert the same JSON back to the notecard with the same python script. But I can see some error logs. It seems some \ symbols added in between the data. In my Req there is no \ symbols.

**Python Script:**

```auto
import json
import notecard
import serial
import time

productUID = "com.gmail.pradeeplogu26:blues_wio_anomaly_detector"

if __name__ == ' __main__':
    ser = serial.Serial('COM22', 115200, timeout=1)
    ser.flush()
    serial = serial.Serial('COM7', 9600)
    card = notecard.OpenSerial(serial, debug=True)

    req = {"req": "hub.set"}
    req["product"] = productUID
    req["mode"] = "continuous"
    card.Transaction(req)

    while True:
        if ser.in_waiting > 0:
            line = ser.readline().decode('utf-8').rstrip()
            print("Serial Data is" + str(line))
            req = {"req": "note.add"}
            req["file"] = "sensors.qo"
            req["start"] = True
            req["body"] = str(line)
            print("Req is : " + str(req))
            card.Transaction(req)
            time.sleep(5)

```

**Error Log:**  **b’{“err”:“body: unmarshal: field body expects object\_raw {io}”}’**

 ![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/d5f9bbdc3180b335135caaa61a8a5e1b944fbe1c.png)

eventhough I tried to replace " with ’ in the received JSON but the issue remains same.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/blues/original/1X/ec0b16826b84f44fc4105faaaf488aef70f4d1a3.png)

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [October 1, 2022, 8:13pm UTC](https://discuss.blues.com/t/req-body-auto-change-issue/1011/2 "2022-10-01T20:13:18Z")

</div>

Hi @Pradeep,

The backslashes are escape characters to allow for a proper display of JSON output. Check out [this Stack Overflow post](https://stackoverflow.com/questions/45193335/remove-backslash-from-json-string) on a similar issue. I haven’t tested this, but my guess is this will help solve your problem:

```auto
json_data = json.dumps(response_read)
json_without_slash = json.loads(json_data)

```

---

<div class="post-metadata">

**Author:** ![Pradeep](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/pradeep/32/479_2.png) [@Pradeep](https://discuss.blues.com/u/Pradeep)\
**Post date:** [October 2, 2022, 4:32am UTC](https://discuss.blues.com/t/req-body-auto-change-issue/1011/3 "2022-10-02T04:32:19Z")

</div>

Hi Rob,

Thanks for the help, I tried to load the JSON and again send to notecard now the return response doesn’t contain backslash, and it’s working.

```auto
import json
import notecard
import serial
import time

productUID = ""

if __name__ == ' __main__':
    ser = serial.Serial('COM22', 115200, timeout=1)
    ser.flush()
    serial = serial.Serial('COM7', 9600)
    card = notecard.OpenSerial(serial, debug=True)

    req = {"req": "hub.set"}
    req["product"] = productUID
    req["mode"] = "continuous"
    card.Transaction(req)

    while True:
        if ser.in_waiting > 0:
            line = ser.readline().decode('utf-8').rstrip()
            json_without_slash = json.loads(line)
            print("Serial Data is " + str(json_without_slash))
            
            req = {"req": "note.add"}
            req["file"] = "sensors.qo"
            req["start"] = True
            req["body"] = json_without_slash
            
            print("Req is : " + str(req))
            card.Transaction(req)
            time.sleep(5)

```
