Data Value submission showing unauthorized statusCode 401 error

I created a custom app for data capture. I had followed the same step like I did with other data capture apps I created which are working fine.

When I login as admin and submit data, it is successful. But when I login with the user account that has the same role like other users of the app, I get the error

httpStatus: "Unauthorized"
httpStatusCode: 401
message: "Unauthorized"
status: "ERROR"

I have checked that the user is assigned to the organisationUnit and the DE is assigned to the dataset.

Is there any other setting I am skipping that could be throwing the error?

Hi @jetisco4u

Does running the browser cache cleaner solve the problem, or did you also do that too?

Caroline

1 Like

Hello @Caroline I clear the cache and refresh the app whenever I switch account. But it doesn’t solve the error.

1 Like

What version are you running?

Also, is there any other user(superuser) that registers data on this particular data set without problems?

Caroline

1 Like

I am using 2.38.1.1

I only try with one superuser account and it is working fine. But with a lesser account it is throwing error 401.

@Caroline I created an account and assigned the superuser role. But unlike the original superuser account, this one throw the unauthorized 401 error.

1 Like

I think I have find the cause of the issue. It is related to the manual user account setting I use to test the app. I forget to comment out the token account.

1 Like

Hi @jetisco4u

Sorry for late response on this.
I’m curious - did this solve your issue?

Caroline

2 Likes

Hi @jetisco4u,

It looks like you are receiving an error with a status of “Unauthorized” and an HTTP status code of 401. This generally means that the request you are making requires some form of authentication, and you have not provided the necessary credentials. The server is rejecting the request because it is not authorized.

The specific cause of the error could be related to a number of factors, including but not limited to:

  • Missing or invalid authentication tokens
  • Insufficient permissions to access the requested resource

To fix this error, you will need to ensure that you are providing the correct authentication credentials and/or have the necessary permissions to access the resource you are requesting. If you are unsure about what is causing the error, you may want to check with the server administrator or the documentation for the App you are using or maybe share settings for the data set.

Best regards,

2 Likes

Thanks and you are right. However earlier questions asked by @Caroline gave me a clue and I was able to detect the cause. I had hard coded a username, password and token for the custom app and forget to comment it out in the live version.

3 Likes