Hi All, I’m trying to add a user using an android app. I can’t quite figure out the syntax. I used the one example in the programmers guide .pdf to get me started, but I can’t quite figure it out.
In the API explorer, I have an example “POST” type, with the url “/ws/v1/users/inventory” and the code sent looks like this: (link to image: https://ibb.co/7VyFkTF)
{
“username”:“”,
“password”:“”,
“email”:“someone@example.invalid”,
“role”:“read_only_user”,
"first_name":"John",
"last_name":"Doe",
"job_title":"Network Administrator",
"phone_number":"202-555-0113",
"address":"9350 Excelsior Blvd Suite 700",
"city":"Hopkins",
"state":"MN",
"postal_code":"55343",
"country":"United States",
"security_policy":"my_policy"
}
On android, I open a connection using my username/password to “https://remotemanager.digi.com/ws/v1/users/inventory”. Then, I try to write similar code:
out.write(“{
“);
out.write(”"username":"mobile-app-test",
“);
out.write(”"password":"S!mplePassWord",
“);
out.write(”"email":"random_email@gmail.com",
“);
out.write(”"role":"read_only_user",
“);
out.write(”
“);
out.write(”"first_name":"test",
“);
out.write(”"last_name":"user",
“);
out.write(”"job_title":"Test-User",
“);
out.write(”"phone_number":"123-456-7890",
“);
out.write(”"address":"1234 Azure Lane",
“);
out.write(”"city":"CityName",
“);
out.write(”"state":"MI",
“);
out.write(”"postal_code":"12345",
“);
out.write(”"country":"United States",
“);
out.write(”"security_policy":""
“);
out.write(”}”);
My first issue is that I do not create a new user, and I’m guessing I am missing html tags, but have no idea what to use here.
My second problem is that I have to close the connection for output and open a new connection for input to receive a response, where an exception is thrown. The exception is a fileNotFoundException for the response URL. Am I wrong to guess that the response would come from the same URL? In Android we can either write to a URL with a variable or read from an URL. Basically, I have to create 2 separate connections.
The java example in the programmer’s guide is sent to /ws/sci and has everything encapsulated in tags, which matches the example in the API explorer. However, in the API explorer there are no tags in creating a user. Here is an image (link: https://ibb.co/GJkxng7) to what that looks like. You can see how they are quite different, and why I have some confusion.
Thanks for any input!