Search code examples
genexusgenexus-sd

Error "Unauthorized" when updating record from smart device grid in Genexus


I have an android app created with Genexus 16U11. In this, I have a grid created with work with smart device. I can insert records but when I try to delete or update them, after I confirm I get the error "Unauthorized", no other explanations. It works in local and in our production server, but not in our test server. What could be causing this problem?

(I know there is a similar question of mine, but that time I didn't solve and the problem returned similar, I have more info this time)

I tried to set debugging in the client.log file but it remains blank. I tried testing with Android Studio and Logcat and got this

2022-06-24 12:19:46.028 4745-4893/com.artech.rts.fotointerventi W/DefaultRequestDirector: Authentication error: Unable to respond to any of these challenges: {}
2022-06-24 12:19:46.031 4745-4893/com.artech.rts.fotointerventi W/System.err: org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONArray
2022-06-24 12:19:46.032 4745-4893/com.artech.rts.fotointerventi W/System.err:     at org.json.JSON.typeMismatch(JSON.java:111)
2022-06-24 12:19:46.033 4745-4893/com.artech.rts.fotointerventi W/System.err:     at org.json.JSONArray.<init>(JSONArray.java:96)
2022-06-24 12:19:46.033 4745-4893/com.artech.rts.fotointerventi W/System.err:     at org.json.JSONArray.<init>(JSONArray.java:108)
2022-06-24 12:19:46.033 4745-4893/com.artech.rts.fotointerventi W/System.err:     at com.artech.common.ServiceErrorParser.parseBody(ServiceErrorParser.java:74)
2022-06-24 12:19:46.033 4745-4893/com.artech.rts.fotointerventi W/System.err:     at com.artech.common.ServiceErrorParser.parse(ServiceErrorParser.java:38)
2022-06-24 12:19:46.036 4745-4893/com.artech.rts.fotointerventi W/System.err:     at com.artech.common.ServiceHelper.responseToServiceResponse(ServiceHelper.java:484)
2022-06-24 12:19:46.036 4745-4893/com.artech.rts.fotointerventi W/System.err:     at com.artech.common.ServiceHelper.doServerRequest(ServiceHelper.java:469)
2022-06-24 12:19:46.036 4745-4893/com.artech.rts.fotointerventi W/System.err:     at com.artech.common.ServiceHelper.doServerRequest(ServiceHelper.java:440)
2022-06-24 12:19:46.037 4745-4893/com.artech.rts.fotointerventi W/System.err:     at com.artech.common.ServiceHelper.putJson(ServiceHelper.java:432)
2022-06-24 12:19:46.037 4745-4893/com.artech.rts.fotointerventi W/System.err:     at com.artech.common.ServiceHelper.updateEntityData(ServiceHelper.java:258)
2022-06-24 12:19:46.037 4745-4893/com.artech.rts.fotointerventi W/System.err:     at com.artech.layers.RemoteBusinessComponent.callService(RemoteBusinessComponent.java:194)
2022-06-24 12:19:46.037 4745-4893/com.artech.rts.fotointerventi W/System.err:     at com.artech.layers.RemoteBusinessComponent.save(RemoteBusinessComponent.java:76)
2022-06-24 12:19:46.037 4745-4893/com.artech.rts.fotointerventi W/System.err:     at com.artech.fragments.LayoutFragmentEditBC$SaveActionTask.saveBCAndMedia(LayoutFragmentEditBC.java:160)
2022-06-24 12:19:46.037 4745-4893/com.artech.rts.fotointerventi W/System.err:     at com.artech.fragments.LayoutFragmentEditBC$SaveActionTask.doInBackground(LayoutFragmentEditBC.java:142)
2022-06-24 12:19:46.038 4745-4893/com.artech.rts.fotointerventi W/System.err:     at com.artech.fragments.LayoutFragmentEditBC$SaveActionTask.doInBackground(LayoutFragmentEditBC.java:69)
2022-06-24 12:19:46.038 4745-4893/com.artech.rts.fotointerventi W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:333)
2022-06-24 12:19:46.038 4745-4893/com.artech.rts.fotointerventi W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2022-06-24 12:19:46.038 4745-4893/com.artech.rts.fotointerventi W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
2022-06-24 12:19:46.038 4745-4893/com.artech.rts.fotointerventi W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
2022-06-24 12:19:46.039 4745-4893/com.artech.rts.fotointerventi W/System.err:     at java.lang.Thread.run(Thread.java:764)

from what I can understand the two servers have the same configurations, what's missing?


Solution

  • I later found out that it was an IIS related problem .

    I can't find the link that helped me

    (I found it https://social.msdn.microsoft.com/Forums/en-US/2f952c19-a209-4df5-8c6d-8de5382ad31e/how-to-enable-put-and-delete-verbs-on-iis-7?forum=iisconfiguationandscripting#f304b2a4-1733-47cb-91e8-84dbc8ad53a6),

    but the problem was that the UPDATE and DELETE verbs were not accepted (similar problem here PUT + DELETE Http Verbs returning 401/405 from API on shared hosting webserver). Entering the IIS Application Authentication and enabling Forms Authentication solved the problem.