It's impossible to tell what you have in each variable. Please provide actual formatted request example.
this is my code check
url = "xyz.demo.com"
traccar_username = "username"
traccar_password = "password"
def login():
response = requests.post(url + '/api/session', data={'email': traccar_username, 'password': traccar_password})
return response.headers.get('Set-Cookie') # here we return jssessionID using session api
def add_geofences():
cookie = login()
headers = {'Cookie': cookie, 'Content-Type': 'application/json'} # Here we add session id to header
params = {'deviceId':3,'geofenceId':15} # here we will create parameter to add device and geofence ID (integer)
r = requests.delete(url=url+ '/api/permissions', headers=headers, params=params)
# and at that point i got this NullPointerException error
SAME ISSUE FOR ADD PERMISSION I GOT
You need to get full stack trace for the exception.
here i got this thing in response
{'_content': b'NullPointerException (PermissionsResource:65 < *:76 < *:93 < ...)', '_content_consumed': True, '_next': None, 'status_code': 400, 'headers': {'Date': 'Mon, 13 Jun 2022 09:27:48 GMT', 'Content-Type': 'application/json', 'access-control-allow-headers': 'origin, content-type, accept, authorization', 'access-control-allow-credentials': 'true', 'access-control-allow-methods': 'GET, POST, PUT, DELETE, OPTIONS', 'access-control-allow-origin': '*', 'Content-Length': '65', 'Server': 'Jetty(10.0.7)'}, 'raw': <urllib3.response.HTTPResponse object at 0x7fd5cee018b0>, 'url': 'http://xyz.demo.com/api/permissions?deviceId=3&geofenceId=15', 'encoding': 'utf-8', 'history': [], 'reason': 'Bad Request', 'cookies': <RequestsCookieJar[]>, 'elapsed': datetime.timedelta(microseconds=301821), 'request': <PreparedRequest [POST]>, 'connection': <requests.adapters.HTTPAdapter object at 0x7fd5d0156100>}
What version are you using?
version 5.0 i am using
It looks like there's some issue with the request, so I think we're back to my original comment:
Please provide actual formatted request example.
This is the real code just URL and credentials are different.
Also i checked in postman and same it gives error 400 bad request
Here I am working in python
There's no need to write in bold. It's not helping with anything.
If you're unable to provide the request, I don't think I would be able to help you any further.
here i want to delete permission between device and geofeceid
here is my code
here cookie is list which contain jssessionid and my traccar domain id
headers = {'Cookie': cookie[0], 'Content-Type': 'application/json', 'Accept': 'application/json'} for geofence in geofence_ids: params = {'deviceId':int(self.ref),'geofenceId':geofence} r = requests.delete(url=cookie[1] + 'api/permissions', headers=headers, params=params)