# Error with json, "No viable alterantive at input"

**URL:** <https://forum.inductiveautomation.com/t/error-with-json-no-viable-alterantive-at-input/103213>\
**Category:** Ignition\
**Tags:** scripting, ignition81\
**Created:** [March 4, 2025, 3:42pm UTC](https://forum.inductiveautomation.com/t/error-with-json-no-viable-alterantive-at-input/103213 "2025-03-04T15:42:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_Hymer](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jon\_Hymer](https://forum.inductiveautomation.com/u/Jon_Hymer)\
**Post date:** [March 4, 2025, 3:42pm UTC](https://forum.inductiveautomation.com/t/error-with-json-no-viable-alterantive-at-input/103213/1 "2025-03-04T15:42:30Z")

</div>

I am trying to run an API all against Plex using an API from their Developer Portal. [PLEX Developer Portal](https://developers.plex.com/docs/custom-fields-api/save-field-values)  
The json for the Request Body is giving me an error in the Script console "no viable alternative at input" where I define the body of the request.  
This is the script

```python
plexusUserNo = 12345
url = "https://connect.plex.com/platform/custom-fields/v1/field-values/save"
header = {"content-type":"application/json", "X-Plex-Connect-Api-Key": "APIKey"}
payload = [0:{"standardObjectName":"Employee", "recordIdentifiers":{"Plexus_User_No": plexusUserNo}, "customFields":{"RFID":5501}}]
client = system.net.httpClient()
response = client.post(url=url, headers=header, data= payload)
ds = system.util.jsonDecode(response.text)
print response
print ds

```

I get the error on the payload at the '0:'

SyntaxError: no viable alternative at input ':' (\< input\>, line 4)

The request body sample from the Dev Portal is

```python
[
  0:{
    standardObjectName:"GLJournalDist",
    recordIdentifiers:{
      Journal_Link:7,
      Line_Item_No:30113464
    },
    customFields:{
      MyBooleanField:true,
      MyCustomObjectRef:{},
      MyDateField:"2023-10-29",
      MyDateTimeField:"2023-10-24T15:50:00Z",
      MyDecimalField:50.75,
      MyIntegerField:20,
      MyPartStandardObjectRef:{},
      MyTextField:"Twenty Two"
    }
  }
]

```

I have successfully used other API calls from the Developer Portal as well as Plex Web Services. but none of those start with the square brackets [..]. I'm not sure what I am missing here and how to format this and get it to work.

Does anybody have any ideas?

---

<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, 2025, 3:44pm UTC](https://forum.inductiveautomation.com/t/error-with-json-no-viable-alterantive-at-input/103213/2 "2025-03-04T15:44:59Z")

</div>

There is no syntax in Python to define a collection using square bracket, key, colon, value, square bracket.

The `0:` in the link you posted is just an attempt to make json array _indices_ clear. You don't actually have to specify them.

That is, it's just saying "the first element in the array you supply should be this", which is as simple to accomplish in Python as:  
`payload = [{"standardObjectName":"Employee", "recordIdentifiers":{"Plexus_User_No": plexusUserNo}, "customFields":{"RFID":5501}}]`

---

<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:** [March 4, 2025, 3:47pm UTC](https://forum.inductiveautomation.com/t/error-with-json-no-viable-alterantive-at-input/103213/3 "2025-03-04T15:47:12Z")

</div>

When you prepare your payload, you are creating **jython** objects (lists and dicts), not actual JSON. The `httpClient` instance does the jython =\> json conversion for you.

Jython doesn't allow you to specify list subscripts within lists, as it doesn't support sparse lists. Just leave out the `0:` in your `payload`.

Edit: sniped by Paul. Sigh.

---

<div class="post-metadata">

**Author:** ![Jon\_Hymer](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Jon\_Hymer](https://forum.inductiveautomation.com/u/Jon_Hymer)\
**Post date:** [March 4, 2025, 3:55pm UTC](https://forum.inductiveautomation.com/t/error-with-json-no-viable-alterantive-at-input/103213/4 "2025-03-04T15:55:13Z")

</div>

Thanks. That worked. I was positive I had already tried that, but sometimes you try so many different things, you forget what you have and have not tried.

Thanks for the help.
