2012-07-25 137 views
12

我使用Google Chrome擴展工具Simple REST Client來測試我的Web服務。如何使用多個參數調用post方法。我在網上搜索,沒有足夠的文件爲這個應用程序。Google chrome擴展簡單REST客戶端

例POST方法

@POST 
    @Path("createcategory") 
    @Consumes("application/x-www-form-urlencoded") 
    @Produces(MediaType.APPLICATION_XML) 
    public void CreateCategory(@FormParam("cname") String cname,@FormParam("cdescription") String cdescription) 
    { 


    CategoriesBO category = new CategoriesBO(); 
    category.setCategoryName(cname); 
    category.setCategoryDescription(cdescription); 

    CategoriesEntityHandler handler = new CategoriesEntityHandler(); 
    try { 
     category = handler.createCategory(category); 


    } catch (Exception e) { 

    } 

} 
+0

您對如何使用Chrome Simple REST Client有疑問嗎?那麼你的問題在這裏脫離主題。 – 2012-07-25 07:38:52

回答

15

This link建議在頭盒和paramlist添加

"Content-Type: application/x-www-form-urlencoded" 

(param1=val1&param2=val2&...) 

在數據框,爲我工作。

1

對於「包頭」,每個報頭需要是上一個新行:

Content-Type: application/json 
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36 

儘管「數據」需要在JSON格式,所以像這樣:

{"login":"USERNAME","password":"PASSWORD"} 

使用一個參數表不適用於我。