Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is wrong with my patch request to the Connectwise Rest API?

Tags:

python

rest

api

I've got a question about the Rest API for Connectwise. I've been doing get and post requests with no issue, but when I do a patch request I get a 400 response with 'field value is invalid' message regardless of what I try. I'm on 2016v1 and using the Rest API making calls from Python with the requests library.

The Rest API documentation says the following object is supposed to be passed in the body, but I haven't a clue what values are supposed to go with these keys:

{
op (string, optional),
path (string,optional),
value (string,optional)
}

I've tried dozens of calls including with the following bodies:

{'summary': 'updatedsummarytext'}
{'value': {'summary': 'updatedsummarytext'}}
{'op': {'summary': 'updatedsummarytext'}}

I have only gotten the following response so far:

<Response [400]>
{
"code": "InvalidObject",
"message": "operations object is invalid",
"errors": [
{
"code": "InvalidField",
"message": "The field value is invalid.",
"resource": "operations",
"field": "value"
}
]
}

Is their a specific value that connectwise is expecting for the op or value keys, or is there something I'm missing unique to Patch rest api calls?

like image 275
Blackjack00 Avatar asked Feb 08 '23 02:02

Blackjack00


1 Answers

The PATCH calls at a basic level use RFC6902.

Consider the following (simplified) Ticket document:

{
  "summary": "Initial Ticket Summary",
  "id": 1,
  "company": {
    "id": 5
  },
  "board": {
    "id": 10
  }
}

If you wish to update the summary field, your PATCH request JSON would look like this:

[
  {"op": "replace", "path": "/summary", "value": "Updated Summary"}
]

Hope this helps.

like image 170
AdamR Avatar answered Feb 10 '23 20:02

AdamR