I'm using the Microsoft Graph REST Beta API call:
POST https://graph.microsoft.com/beta/bookingBusinesses/{id}/customers
With body payload:
{
"displayName": "User Name",
"emailAddress": "email%40eventhorizon.llc"
}
I get a 201 response (success). But the data in Bookings is corrupted when I look at the interface, and so is the JSON response, which has a blank email, etc. although I sent this data to the API. Can anyone tell me what I'm doing wrong?
JSON Response (note that it picks up the email address in the ODATA):
{
'@odata.context':'https://graph.microsoft.com/beta/$metadata#bookingBusinesses('email%40eventhorizon.llc')/customers/$entity',
'id':'ee6004dd-c4af-435d-b3a9-532b2753753e',
'displayName':'ee6004dd-c4af-435d-b3a9-532b2753753e',
'emailAddress':null
}
Java Code:
IAuthenticationResult auth = msft.getAuth();
String accessToken = auth.accessToken();
URL url = new URL(urlString);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Authorization", "Bearer " + accessToken);
conn.setRequestProperty("Accept", "application/json");
conn.setRequestMethod(method);
if (method.equalsIgnoreCase("POST") || method.equalsIgnoreCase("PUT")) {
conn.setRequestProperty("X-HTTP-Method-Override", "PATCH");
conn.setDoOutput(true);
String str = payload.toString();
OutputStream out = conn.getOutputStream();
out.write(str.getBytes());
out.flush();
}
httpResponseCode = conn.getResponseCode();