Hello! I'm trying to organize the registration of a user from the android application on the server through the ASP.NET API. Form data is sent via POST. JAVA code:

@POST("/app/accounts/register") Observable<Integer> userRegistration(@Body UserAPI body); 

UserAPI class:

 public class UserAPI { @SerializedName("id") @Expose private int id; @SerializedName("sid") @Expose private int sid; @SerializedName("full_name") @Expose private String full_name; @SerializedName("iin") @Expose private String iin; ...} 

The implementation of the userRegistration function:

 @Override public Observable<Integer> userRegistration(UserAPI body) { return apiInterface.userRegistration(body) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } 

In the service controller (ASP.NET, C #):

 // /app/accounts/register [HttpPost] [ActionName("Register")] public int Register(User user) { return mModel.registerUser(user); } 

User class in service:

 public class User { public int id { get; set; } public int sid { get; set; } public string full_name { get; set; } public string iin { get; set; } } 

When sending from the application, android errors do not occur, however, the service does not react either, and in response a 404 error comes. What's my mistake.

  • Is there a permission to the Internet in the manifest? - Yuriy SPb
  • All permissions are there. Moreover, get requests pass and are processed. The problem is only with POST. - mg-demin
  • Well ... Maybe your URL is somehow wrong as a result. Maybe the first slash is superfluous (or the last one is still needed). Maybe you have a space somewhere in the address and it is not automatically converted to %20 and, as a result, you simply ignore it and you get an invalid query. - Yuriy SPb
  • and comes to the public int Register(User user) method on the server? also check out the routs for this action - Grundy

1 answer 1

Carefully analyzing the application and server code for compliance and correctness of the formation of addresses on the advice of YuriySP, identified and eliminated an incorrect address. However, to completely solve the problem, it was necessary to make changes to the controller code:

 [HttpPost] [ActionName("Register")] public int Register([FromBody] User user) { return mModel.registerUser(user); } 

Namely - add annotation [FromBody]. Thank you all for your attention.