Good Day B4X'ers,
I am trying to get a response from a sandbox api by adding a driver to a logistics system. Somewhere, somehow I am getting it wrong and being new at this (api's) can't seem to find the problem.
Documentation HERE
Project Attached (It looks at a Sandbox - so passwords etc will expire soon)
The Error Code
The json is in a file named Driver.txt in the project and also below
According to eLogii support - the above json is the minimum requirement to be successful and works on their side.
The Offending Code (imho)
All help/direction pointing is appreciated.
I am trying to get a response from a sandbox api by adding a driver to a logistics system. Somewhere, somehow I am getting it wrong and being new at this (api's) can't seem to find the problem.
Documentation HERE
Project Attached (It looks at a Sandbox - so passwords etc will expire soon)
The Error Code
The Error Code:
{"statusCode":400,"error":"Bad Request","message":"Invalid request parameters","data":{"details":"\"userInfo\" is required"}}
The json is in a file named Driver.txt in the project and also below
Driver json:
{
"userInfo": {
"username": "[email protected]",
"password": "apphub123"
},
"firstName": "Petrus",
"lastName": "Jabulane",
"mobile": "0820511248",
"mobile2": "0820511233",
"email": "[email protected]",
"startLocation": {
"type": 2,
"uid": "ev0001",
"name": "Medipost Head Office",
"address": "593 Nico Smith St",
"addressLine2": "Gezina",
"postCode": "0084",
"city": "Pretoria",
"country": "South Africa",
"coordinates": [
"28.20845",
"-25.71996"
],
"contactName": "Nico",
"contactPhone": "Van Der Merwe",
"setupDuration": 15,
"serviceDuration": 15
}
}
According to eLogii support - the above json is the minimum requirement to be successful and works on their side.
The Offending Code (imho)
Offending Code:
Dim j As HttpJob
j.Initialize("eLogii", Me)
Dim sendtxt As String
sendtxt = File.ReadString(File.DirAssets,"Driver.txt")
Log(sendtxt)
If sendtxt.Length > 0 Then
j.poststring( "api-sandbox.elogii.com/drivers", sendtxt)
j.Username = "[email protected]"
j.Password = "apphub123"
' I seriously have no idea what must be here below
j.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36")
j.GetRequest.Setheader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
j.GetRequest.Setheader("Content-Type", "application/json")
j.GetRequest.SetContentEncoding("text/plain")
j.GetRequest.SetHeader("host","http")
j.GetRequest.SetHeader("proxy-connection","keep-alive")
j.GetRequest.SetHeader("Authorization", "ApiKey 613b6addb175360017ec93ab:tbD5Q03OupBPqNWl_5rxs")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log("Success!!!")
Log(j.GetString)
Else
Log("OOPS")
Log(j.ErrorMessage)
End If
j.Release
End If
All help/direction pointing is appreciated.