0

I am trying to update a field using an API call. I want to update the value field for the below

[{'category': 'Category1', 'label': 'Component1', 'value': 10.0}, 
 {'category': 'Category2', 'label': 'Component2', 'value': 200}]

I am trying to update the value of Component1 from 10.0 to 20.0

I pass the payload as below

payload = {'customFields':{'label': 'Component1', 'value' : 20.0}}

headers = {'Authorization': 'Bearer ' + access} 
response = requests.request("PATCH", url, headers=headers, json=payload)

This throws an error

"Invalid type. Expected Array but got Object."
Kevin Nash
  • 1,511
  • 3
  • 18
  • 37
  • I don't think the problem is in the python code. The issue might be in the server server side whatever `url` is executing. Debug the requests PATCH request. https://stackoverflow.com/questions/10588644/how-can-i-see-the-entire-http-request-thats-being-sent-by-my-python-application – Tk421 Jul 22 '21 at 09:37
  • @Tk421 thanks for responding. I am able to update other fields using the same url and syntax. It is just this one field who structure is like a dict within a list and I am trying to update one of the values in that dict – Kevin Nash Jul 22 '21 at 09:39
  • My approach for this type of problems would be to get the call working with `curl` (o postman) and after than just compare with actual HTTP request/response that is being sent via python requests. But if the end point is requesting an array, did you try to give it an array (eg. `payload = [{'customFields':{'label': 'Component1', 'value' : 20.0}}]`) – Tk421 Jul 22 '21 at 09:48
  • @Tk421 it returns the message `{"message":"The request is invalid."}` – Kevin Nash Jul 22 '21 at 10:11
  • My guess is that the issue is in the backend side, not in the python client code. Try to reproduce the API call with Postman or Curl and once you have it working apply the same to the python script. – Tk421 Jul 23 '21 at 01:09

0 Answers0