Home/Support/Support Forum/Java/Android - Creating A User Programmatically in DRM
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Java/Android - Creating A User Programmatically in DRM

0 votes
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)


"job_title":"Network Administrator",
"address":"9350 Excelsior Blvd Suite 700",
"country":"United States",


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("\"address\":\"1234 Azure Lane\",\n");
out.write("\"country\":\"United States\",\n");

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!
asked Nov 18 in Web Services by FoxDonut New to the Community (1 point)
I found, within the Digi Remote Programmer Guide, a table for v1/users. This is at the top of page 273. It shows that I need to use "PUT" for creating a user. This is different than what API Explorer shows, which uses "POST." I'll give this a try and report back.
So, it looks like I either can't read documentation properly, or it was wrong about using PUT, as using this threw an error. Again, I saw this on page 273 of the Digi Remote Programmer Guide. It is absolutely necessary to use POST.

Please log in or register to answer this question.

1 Answer

0 votes
I ended up using the Volley library and solved this:

As a hint to others, I set the Header Content Type to ("Content-Type", "application/json"), and the body Content Type to "application/json; charset=utf-8". Use POST, not PUT.

Hopefully this helps someone at some point!
answered Nov 19 by FoxDonut New to the Community (1 point)