Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
avatar image
0
Question by siddharth3322 · Jun 16, 2016 at 08:17 AM · unity 5serverwwwwebrequestwwwform

Data pass using POST method - WebRequest object

I want to use POST method to pass data over web server. I want to retrieve data provided by web server in JSON format. I have used following code by referring Unity Manual.

     void Start ()
     {
         StartCoroutine (LoadLoginInfo ());
     }
 
     IEnumerator LoadLoginInfo ()
     {
         Debug.Log("Load Login Info");
 
         WWWForm form = new WWWForm ();
         form.AddField ("username", "admin");
         form.AddField ("password", "Admin123#");
 
         UnityWebRequest www = UnityWebRequest.Post (url, form);
         yield return www.Send();
 
         if (www.isError) {
             Debug.Log (www.error);
         } else {
             Debug.Log ("Login Data Retrieved");
         }
     }

But after certain amount of wait, I am getting following message in console.

alt text

I have already checked this thing into browser but at their everything working normal.

alt text

So what is the correct way to use POST method using WebRequest object?

screen-shot-2016-06-16-at-20401-pm.png (16.7 kB)
screen-shot-2016-06-16-at-20044-pm.png (60.5 kB)
Comment
Add comment · Show 1
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 siddharth3322 · Jun 16, 2016 at 05:21 PM 0
Share

Any help in this? You can try with your URL too.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by disny1234 · Aug 18, 2017 at 09:02 PM

Add Debug.Log(request.downloadHandler.text); See code below

void Start() { StartCoroutine(Post()); }

 IEnumerator Post()
 {
     WWWForm wwwf = new WWWForm ();
     wwwf.AddField("object_or_array", "object");
     wwwf.AddField("empty", "false");
     wwwf.AddField("parse_time_nanoseconds", "78983");
     wwwf.AddField("validate", "true");
     wwwf.AddField("size", "1");

     var request = UnityWebRequest.Post("http://validate.jsontest.com/?json=%7B%22key%22:%22value%22%7D", wwwf);

     yield return request.Send();

     Debug.Log(request.downloadHandler.text);
 }


response output { "object_or_array": "object", "empty": false, "parse_time_nanoseconds": 46600, "validate": true, "size": 1 }

Comment
Add comment · 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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

79 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 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 files to a remote form using C# in Unity 2 Answers

HTTP requests in Unity 5 0 Answers

Failed to upload image over custom server 3 Answers

Blank web server response in multiple type data submission 1 Answer

$_FILES is empty when I send a file from WWWForm 2 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