Tell me how to send the Json request


Luxembourg
24/4/2016 9:44 am
HOME ยป Web Development

I am sending the json request code give the error Is there any way how to send the json request with authentication.this Code give the Error in filenotfound "http://api.seatseller.travel/blockTicket"
//st = json object

       StringBuilder sb = new StringBuilder();  
         JSONObject jsonParam = st;//JSON 
         HttpURLConnection request=null; 
        OAuthConsumer consumer = new
DefaultOAuthConsumer("tOzL5hTkSz9KiA2RIAECW4g7Uq","cj8HLPmBKnRAsffLe5qpQIZ9Y");
        consumer.setTokenWithSecret(null, null); //i pass token as
access token as a null as my server dont need it.

        URL url = new URL("http://api.seatseller.travel/blockTicket");
          request = (HttpURLConnection) url.openConnection();
        request.setDoOutput(true);   
        request.setRequestMethod("GET"); 
        request.setUseCaches(false);  
        request.setConnectTimeout(10000);  
        request.setReadTimeout(10000);  
        request.setRequestProperty("Content-Type","application/json");
  

        request.setRequestProperty("Host", "android.schoolportal.gr");


        consumer.sign(request);
        request.connect();
        OutputStreamWriter out = new  
OutputStreamWriter(request.getOutputStream());
        out.write(jsonParam.toString());
        out.close();  
        int HttpResult =request.getResponseCode();  
        if(HttpResult ==HttpURLConnection.HTTP_OK){  
            BufferedReader br = new BufferedReader(new
InputStreamReader(  
                    request.getInputStream(),"utf-8"));  
            String line = null;  
            while ((line = br.readLine()) != null) {  
                sb.append(line + "
");  
            }  
            br.close();  

            System.out.println(""+sb.toString());  

        }else{  
                System.out.println(request.getResponseMessage());  
        }  
    } catch (MalformedURLException e) {  

             e.printStackTrace();  
    }  
    catch (IOException e) {  

        e.printStackTrace();  
        } 
     catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Related to : Tell me how to send the Json request
JSON IPHONE: How to send a JSON request and pull the data from a server?
Web Development

I know barely nothing about JSON and I need to send a request to a server and read the data coming from it, using the iPhone only.


I have tried to use the jason-framework
to do that, but after readin the documentations I was not able to figure out how to construct the object and send it on the request. So I decided to adapted another code I saw here on SO.


The Object I need is this:


{ "code" : xxx }


Here I have a problem. This xxx is a NSData, so I suspect that I have to convert this data to a string, then use this string to build an object and send this on the request.


the server re

Unable to send JSON object as request parameter as JSON.stringify gives circular reference error
Web Development

I have a tree, to be displayed on the screen, which is basically a JSON object. I want to send this JSON object to the Java class as a request parameter.


Following is a sample of the JSON object:


// Root node
var rootNode = { Content: "Root", Nodes:[] };
// First Level
rootNode.Nodes[0] = { Content: "Employee Code", navigationType: "0"};
rootNode.Nodes[1] = { Content: "Problem Area", navigationType: "1" };
// Second Level
rootNode.Nodes[1].Nodes = [{ Content : "ACC-HO", Collapsed: true},
{ Content : "ACC-SALES" },
{ Content : "BUSI.
ExtJs 4.1 : How to send json data in the request body using Ext.Ajax.request()?
Web Development

I would like to send json data using Ext.Ajax.request() then access it in ASP.NET using Request.InputStream which is the content of the request body. I need a way to tell ExtJs to write the data in the request body as it is done while using an Ext.data.proxy.Ajax.


How to send JSON request parameters while submitting the form? (instead of $.ajax request)
30/12/2014 5:40 pm Web Development

How to send JSON request parameters to server while submitting the form?

function fun2() {
alert("in fun2");
document.searchForm.action =
"http://localhost:8080/DatasetRepo/rest/downloadZip?"+"{'datasets':['1'],'token':'myfirsttoken'}";
document.forms["searchForm"].submit();}      

and its failing with Unsupported media type error.




HD Wallpapers
3D
3D Abstract
City
Celebrities
Indian Celebrities
Cars
Travel
Girls
Animals Birds
Movies
Sports
Black White
Nature
Planes
Anime
Food Drink
Dreamy Fantasy
Architecture
Games
Space
Holidays
Flowers
Love
Artistic
Baby
Beach
Bikes Motorcycles
Macro
Computers
Vector
Funny
Army
Textures
Brands
Misc
Music
Other
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .