Hello,
I’m trying to POST an update for an Entity (Passenger) having a foreign key (lastOnBoardShift).
Passenger has several Mandatory or Unique attributes and just one which is both (taxCode).
I want to update lastOnBoardShift only, on Passenger instances having taxCode -obviously- already defined.
Here some Python code:
def update_passenger(self, token, passenger):
passenger_id = passenger['id'].encode('ascii', 'ignore')
url = '%s/app/rest/v2/entities/bustrack$Passenger/%s' % (self.addr, passenger_id)
auth_header = 'Bearer ' + token['access_token'].encode('ascii', 'ignore')
headers = {'Authorization': auth_header, 'content-type': 'application/json'}
entity_json = json.dumps({'lastOnBoardShift': passenger['lastOnBoardShift']})
resp = requests.put(url=url, data=entity_json, headers=headers)
return resp
The HTTP response is always 400, and the reason is I don’t provide the taxCode.
If I put the taxCode again in the HTTP json data everything works as expected
entity_json = json.dumps({'taxCode': passenger['taxCode'], 'lastOnBoardShift': passenger['lastOnBoardShift']})
What is wrong?
Besides, I don’t have errors in the Tomcat log
Thanks