RestClient中的POST方法使用Rails

时间:2016-09-06 07:47:46

标签: ruby-on-rails rest-client

我正在尝试使用RestClient发布值。它总是显示以下错误。

  

RestClient :: BadRequest(400 Bad Request):

在SO中尝试了所有答案。什么都没有帮助。这是我的代码。

  

response = RestClient.post“http://192.72.114.66/WDSTEST_WS/WDS_SERVICE.svc/companymaster/Add”,{“CompanyMaster”:{“Address1”:“Raja Street cbe”,“BussinessProfile”:“lll”,“City”:“statee”,“CompanyID” “:24,”CompanyName“:”Ramu Metall“,”CreatedBy“:138,”Email“:”abcd@gmail.com“,”IsActive“:true,”LandLine“:”435435“,”MobileNumber1“:” 8787871221" , “ModifiedBy”:138, “PIN码”:0, “备注”: “空”, “国家”: “空”, “TonnageKM”: “0”, “TotalInsurableGoodValueForPreviousYear”:0.00, “TotalInsurableGoodValuePerYear”:0.00 ,“TotalTransportationCostForPreviousYear”:0.00,“TotalTransportationCostPerYear”:0.00,“TotalTransportedWeightPerYear”:0.00,“Website”:“null”}},标题:{“Content-Type”=> “应用程序/ JSON”}

这只是一个虚拟数据。 请帮忙。提前谢谢。

1 个答案:

答案 0 :(得分:2)

最后,我解决了它。格式有误。正确的格式是,

b