I'd like to use ajax to retrieve a token.
In accordance to this documentation, below is the URL, request headers, and request body
POST https://api-production.august.com/session
Request Headers:
x-august-api-key: 727dba56-fe45–498d-b4aa-293f96aae0e5
x-kease-api-key: 727dba56-fe45–498d-b4aa-293f96aae0e5
Content-Type: application/json
Accept-Version: 0.0.1
User-Agent: August/Luna-3.2.2
Request Body: (JSON Encoded)
{
"installId": <Random UUID>,
"password": "XXXXXXXX",
"identifier": "phone:+15555551234"
}
I've tried to implement this with ajax as such
$.ajax({
type: "POST",
url: "https://api-production.august.com/session",
dataType: "json",
headers:{
"x-august-api-key":"727dba56-fe45–498d-b4aa-293f96aae0e5",
"x-kease-api-key":"727dba56-fe45–498d-b4aa-293f96aae0e5",
"Content-Type": "application/json",
"Accept-Version": "0.0.1",
"User-Agent": "August/Luna-3.2.2"
},
data: JSON.stringify({installId: "7fb17963-21a8-4c23-8f81-121ed3298ad8",
password: "password",
identifier: "phone:+18885554444"})})
However I dont get the token and I get the following response:
abort: function abort()
always: function always()
catch: function catch()
done: function add()
fail: function add()
getAllResponseHeaders: function getAllResponseHeaders()
getResponseHeader: function getResponseHeader()
overrideMimeType: function overrideMimeType()
pipe: function pipe()
progress: function add()
promise: function promise()
readyState: 0
responseJSON: undefined
setRequestHeader: function setRequestHeader()
state: function state()
status: 0
statusCode: function statusCode()
statusText: "error"
then: function then()
The error is the following:
my error: ajax TypeError: Cannot convert string to ByteString because the character at index 13 has value 8211 which is greater than 255.
I've also tried running this in google chrome, but I get the following error:
"TypeError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': Value is not a valid ByteString."
I've also tried the following to no avail as I get the same error:
$.ajax({
type: "POST",
url: "https://api-production.august.com/session",
dataType: "json",
beforeSend: function(request) {
request.setRequestHeader("x-august-api-key", "727dba56-fe45–498d-b4aa-293f96aae0e5");
},
data: JSON.stringify({installId: "7fb17963-21a8-4c23-8f81-121ed3298ad8",
password: "password",
identifier: "phone:+18885554444"})})