I’m trying to use the Java Management API to sign my users up using a Non Interactive Client, however I am getting errors with the body of my request when using Unirest:
// Request to create user
HttpResponse<String> createUser = Unirest.post(plugin.getConfig().getString("Auth0.Credentials.API.Identifier") + "users")
.header("authorization", APIToken.getString("token_type") + " " + APIToken.getString("access_token"))
.body("{\\\"connection\\\":\\\"CONNECTION\\\",\\\"email\\\":\\\"EMAIL\\\",\\\"username\\\":\\\"USERNAME\\\",\\\"password\\\":\\\"PASSWORDSTRING\\\",\\\"app_metadata\\\":{\\\"given_name\\\":\\\"USERNAME\\\",\\\"picture\\\":\\\"PICTUREURL\\\"},\\\"email_verified\\\":true}")
.asString();
That’s the minified version of the body, following the guide which escapes the quotations. When I put use this code it returns this:
{"statusCode":400,"error":"Bad Request","message":"Payload validation error: 'Expected type object but found type string'.","errorCode":"invalid_body"}
I’m unsure as to why this isn’t working, am I missing something? The token is being accepted because it returns with a valid error code.