Announcement Announcement Module
Collapse
No announcement yet.
How to use the put() Method right? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use the put() Method right?

    Hey there,

    i'm trying to build an app, which can interact with an webserver. It's already able to download XML files with the get() Method. But i want to upload XML Data too. I haven't found any examples for a put() operation yet and all things i tried failed.

    I tried it this way:

    Code:
    private class SendXMLActivity extends AsyncTask<Message,Void, String> {
        	protected String doInBackground(Message...msg) {
        		String str;
    
        		try
        		{
        			// Create a new RestTemplate instance
        			RestTemplate restTemplate = new RestTemplate();
    
        
        			restTemplate.getMessageConverters().add(new SimpleXmlHttpMessageConverter());
        			restTemplate.getMessageConverters().add(new StringHttpMessageConverter());
        			
    
       
        			
        			 restTemplate.put("http://10.0.2.2:8080/testservlet/static",msg);
        			 str="XML gesendet!";
        			
        		}
        		catch(Exception e)
        		{
        			Log.e("SendXML",e.getMessage(),e);
        			str=e.getMessage();
        		}
        		return str;
        		
        	}
        	
        	protected void onPostExecute(String response) {
        		Toast.makeText(TestAppActivity.this,response, Toast.LENGTH_SHORT).show();
        		
        	}
        }
    I get the following Error Log
    Code:
    Could not write request: no suitable  HttpMessageConverter found for Request type
    It seems that the put operation is'nt the problem right now. But which Message Converter should I use? I tried the same request once just with a string, wich caused an error 403-forbidden. I'm just starting to make android apps and using spring, so don't blame me if my Problems are too obvious .

    Hope you can help me.
    regards
    Erik
Working...
X