Hi, i am trying to call my Rails app using Java code using Jersey
I m having 2 tables .
Blogposts (id,name,slug,desc) Comments (id,data,node_id,node_type)
I m trying to post a comment through my ruby code.
The Url for me is like http://localhost:3000/api/blogs/comment.xml?slug=blogtitle-0&comment=aaaaaaaaaaaaaaa
The one is tried is blogBean = objBlogWrapper.postComment(slug,comment);
public BlogBean postComment(String slug, String comment) { System.out.println(slug+""+comment); // Create a multivalued map to store the parameters to be send in the REST call MultivaluedMap<String, String> newBlogParam = new MultivaluedMapImpl(); // newBlogParam.add("blogpost[slug]", slug); // newBlogParam.add("comment[data]", comment); newBlogParam.add("slug", slug); newBlogParam.add("comment", comment);
BlogBean blogBean = null; try { blogBean = webResource.path(ConfigurationUtil.POST_COMMENT).header(ConfigurationUtil.AUTHENTICATION_HEADER, authentication) .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).accept(MediaType.APPLICATION_XML_TYPE).post(BlogBean.class, newBlogParam);
}catch (UniformInterfaceException uie) { if (uie.getResponse().getStatus() == 401) { System.out.println("Can not authenticate user "+ConfigurationUtil.userName + ". Please check your username/password and try again." ); } else { System.out.println("Error when trying to talk to app. " + "HTTP status code "+uie.getResponse().getStatus()+"returned. Finishing.");
} return null; } catch (ClientHandlerException che) { System.out.println("Error when trying to talk toapp. Network issues? " + "Please check the following message and try again later: "+che.getMessage()); return null; } return blogBean; }
where my ConfigurationUtil.POST_COMMENT="api/blogs/comment.xml";
The above doesnt show me any error nor the comment is posted ..
Please give suggestions.