Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 lokindia · Jun 24, 2013 at 06:07 PM · wwwjson

POST using WWW isn't working

Hi there! I'm calling a restful web API from OnGUI() on clicking a GUI.Button. But the method I'm calling always gives me "500 Internal Server Error". I have tested the same web API using Simple REST Client (Chrome Plugin) and it works for the same data and url I'm using in the method below. Please help.

The code segment:

 >     function RestCallUsingPOST()
 >     {
 >         var strInput : String = "{\"uuid\":\"97182345\"}";
 >         var objHeaders : Hashtable = new Hashtable();
 >         objHeaders.Add("Content-Type","application/json");
 >         
 >         var body : byte[] = System.Text.Encoding.UTF8.GetBytes(strInput);
 >         
 >         var objPOST : WWW = new WWW("http://ec2-54-251-161-31.ap-southeast-1.compute.amazonaws.com/api/v1/user/GetUserBalance",
 > body, objHeaders);
 >         yield objPOST;
 >         
 >         if(objPOST.error == null)
 >         {
 >             print(objPOST.text);
 >         }
 >         else
 >         {
 >             print("Web invoke error: "+objPOST.error);
 >         }
 >     }
Comment
Add comment · Show 3
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 hiddenspring81 · Jun 24, 2013 at 08:10 PM 0
Share

A web-service should never return a 500 level error. Five hundred level errors mean that the server choked while handling the request. Ideally, if the request isn't properly formatted, then the appropriate response would be 400 (bad request). Is this a web-service that you've created, or are you hooking into someone else's web-service?

avatar image Benproductions1 · Jun 25, 2013 at 09:30 AM 0
Share

Please format your code, it's not hard and makes it easier for the people here to answer your question for free :) If you don't know how, watch the tutorial video

avatar image lokindia · Nov 12, 2013 at 07:20 AM 0
Share

The code works fine, there was nothing wrong in the code above. It was a problem at web-service end. Thanks hiddenspring81 for showing me the path to server end, there's another which makes webservice so I had to sit with them to debug the request handling at webservice end.

0 Replies

· Add your reply
  • Sort: 

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

17 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

Related Questions

Problem Parsing Json (JsonUtility) 1 Answer

Streaming Assets android 0 Answers

Need to create a structure that will represent the JSON answer from OpenWeather 0 Answers

JSON Error : ArgumentException: JSON must represent an object type. 1 Answer

how to find if WWW Post Request is succesful? 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