Trying to use PATCH on a UnityWebRequest on Android and getting 'Unsupported Protocol'
Hi
Really hope someone can assist, we are using Azure Mobile App Service and everything works fine in the editor and on IOS, we only have a problem on Android when trying to update an existing record.
According to the Azure resource documentation you need to use Patch
PATCH /tables/tablename/:id Update an existing record in the table
When testing on an Android device it does not even try to send the web request it simply returns error: "Unsupported Protocol"
The research shows that there are workaround solution but I have not found anything relevant to Unity.
I did a search on the forum for HttpMethod.Patch but could not find a single article. Really having some trouble understanding how to resolve the issue and if there is a way to resolve it in Unity.
Any help would be greatly appreciated.
Thanks in advance.
Just thought I would add this, according to the Unity documentation found here: https://docs.unity3d.com/$$anonymous$$anual/UnityWebRequest.html
Platforms supported in 5.3:
$$anonymous$$obile Platforms: iOS, Android, Windows Phone 8
Set HTTP verb (GET, POST, HEAD, etc.)
Custom verbs are permitted (So we added Patch)
This should work no problem, but it does not even try to do the UnityWebRequest it just returns the error: 'Unsupported Protocol'
Seeing that the official documentation states that this should work, could this be a bug in UnityWebRequest?
Answer by dgkanatsios · Aug 31, 2016 at 09:52 AM
Just fixed using Easy APIs on Azure https://github.com/dgkanatsios/AzureServicesForUnity
Thank you very very much, your solution is working. Now able to update Azure Easy Table records via the Easy API from Android device.
For anyone looking for a backend database solution working with Unity, well worth looking at this solution,
https://dgkanatsios.com/2016/04/14/use-azure-services-from-unity/
Answer by Yury-Habets · Aug 18, 2016 at 06:36 PM
The best bet would be to capture the packets and see if Android sends the correct one. Are all the other verbs working OK on Android?
Hi
Been using Fiddler to check the traffic, all the other verbs we are using are working correctly.
However Fiddler is not recording any Patch request. We are updating an entry by ID so we can see that it gets the correct record but then nothing else, this does work 100% in the editor and on IOS.
On Android there is no patch request leaving the device, just the message that the protocol is not supported.
I can share the Fiddler logs but as mentioned there is no request to see what is being sent.
Please submit a bug report, with your project attached, and the Fiddler logs. Thanks!
Hi
Bug report has been submitted.
Thanks
Bug details
(Case 824415) Trying to use PATCH on a UnityWebRequest onAndroid and getting 'Unsupported Protocol
Actually this is by design. Android supports only verbs from the standard: https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
Everything else generates an exception, for the security reasons.
I'm closing your bug report as "By Design" and updating the Unity documentation.
I don't understand why it would be "ok" on iOS, what would be the point? Having said that you guys are the experts, what would the solution be then to get patch working on android?
I'm on the Android $$anonymous$$m and have no idea why that works on iOS :) Android is using Java classes, which follow the W3C standard. It's hard to blame it for following the standard, isn't it?
Answer by deadlyfingers · Nov 22, 2016 at 05:09 PM
You can also install "method-override" for Azure App Services (node backend) to get PATCH to work on Android using UnityWebRequest.
1) Add "method-override": "^2.3.7" to your "package.json" dependencies by running:
npm install method-override --save
2a) Insert the following to your "app.js" express app config (this is explained in the method-override readme)
var methodOverride = require('method-override');
2b) Then after the line var app = express();
add:
app.use(methodOverride('X-HTTP-Method-Override'))
3) Now change your update request from "PATCH" to "POST" and add the header:
X-HTTP-Method-Override: PATCH
This will enable the override header and allow you to perform PATCH updates using POST requests which are allowed on Android.
Thanks for this, i will get the $$anonymous$$m to look at it and get back to you. We decided to use a node.js rather, to avoid the entire ordeal and currently working with a backend fix. again thanks for your solution, will test it asap.