Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Mar 05, 2019 at 04:31 PM by Bunny83 for the following reason:

The question is answered, right answer was accepted

avatar image
14
Question by elenzil · Mar 30, 2016 at 04:58 PM · wwwhttppost

prevent UnityWebRequest.Post() from Url-Encoding the data ?

per the docs for UnityWebRequest.Post(), the post body "Will be URLEncoded via WWWTranscoder.URLEncode prior to transmission".

this is crazy. nowhere does the HTTP spec require that POST data be URL-Encoded. a good HTTP client should assume the user (me) knows what they're doing and can URL-Encode their own data if required. look at Curl. does Curl automatically url-encode the body if the method is POST ? no. if you're writing an HTTP client and you find yourself diverging from what Curl does, check yourself. < /rant >

anyhow, is there a way to disable this ? i've tried: setting the content type "text/plain" setting the UploadHandler's content type to "text/plain"

neither works.

a workaround that does seem to work but is a total hack is to use UnityWebRequest.Put() instead, and change the method to POST before Sending it.

also, this is a change from the previous WWW HTTP Client framework, and the statement in the manual that "For end-users who only employ common WWW use cases, transitioning to the new system should be almost a find-and-replace process." is way off-base because of this.

Comment
Comments Locked
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
17
Best Answer

Answer by elenzil · Mar 30, 2016 at 05:25 PM

better workaround than the WebRequest.Put() hack is to build a WebRequest 'from scratch':

   request                 = new UnityWebRequest(url);
   request.uploadHandler   = new UploadHandlerRaw(myStringToByteArrayConverter(body));
   request.downloadHandler = new DownloadHandlerBuffer();
   request.method          = UnityWebRequest.kHttpVerbPOST;
Comment
Comments Locked · Show 10 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image elenzil · Apr 21, 2017 at 11:53 PM 3
Share

funny; a year and a month later, i ran into this problem again, and completely re-diagnosed it again w/ WireShark, then googled for something appropriate and found this... memory like a sieve.

avatar image nilsubimax elenzil · Sep 28, 2017 at 01:09 PM 2
Share

Thanks for being the internet hero we do not deserve and answering your own question. Exactly my problem, solution worked like a charm. https://xkcd.com/979/

avatar image elenzil nilsubimax · Sep 28, 2017 at 04:07 PM 0
Share

sweet, glad it came in useful.

avatar image Fragmental elenzil · Apr 04, 2018 at 06:44 AM 1
Share

Runs into problem. Googles solution. Finds own solution.

avatar image Zero_MSN · Oct 11, 2017 at 07:03 PM 0
Share

Thank you so much for this. I've spent hours trying to figure out why I was getting errors when posting JSON data to a .NET Web API service. Your solution solved it for me.

avatar image Eric-Eidel · Nov 06, 2017 at 09:12 AM 0
Share

Such an easy work around! Thanks, this was driving me crazy, the server side of things for me is a node.js express stack and bodyPraser.json() doesn't work with url encoded jsons...

avatar image tarahugger · Apr 18, 2018 at 01:48 PM 0
Share

Dear Barbara, another year has passed and unsuspecting Unity users are still being baffled by 415 Unsupported $$anonymous$$edia Type responses. It makes no sense to me why, in the json world we live in, when you already have multiple overloads for form data, that a string argument overload would assume application/x-www-form-urlencoded.

avatar image AlexAba · Feb 02, 2019 at 07:28 PM 0
Share

Thank you so much man. I have spend all f*cking day to solve this problem, and at the end I found your answer.

Show more comments

Follow this Question

Answers Answers and Comments

50 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Upload large files 0 Answers

HTTP Response Headers? 3 Answers

Try catch alternative for HTTP request 1 Answer

Unity WWW Warning Message in Xcode 1 Answer

Using Unity and sails CSRF Problem 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges