POST RestClient 中的方法使用 Rails
POST method in RestClient using Rails
我正在尝试使用 RestClient post 值。它总是显示以下错误。
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,"PinCode":0,"Remarks":"null","State":"null","TonnageKM":"0","TotalInsurableGoodValueForPreviousYear":0.00,"TotalInsurableGoodValuePerYear":0.00,"TotalTransportationCostForPreviousYear":0.00,"TotalTransportationCostPerYear":0.00,"TotalTransportedWeightPerYear":0.00,"Website":"null"}}, headers: {"Content-Type" => "application/json"}
这只是一个虚拟数据。
请帮忙。提前致谢。
终于解决了。格式有误。正确的格式是
response = RestClient.post "http://192.72.114.66/WDSTEST_WS/WDS_SERVICE.svc/companymaster/Add", {"CompanyMaster": {"Address1":"Ganapathy","Address2":"Coimbatore","BussinessProfile":"null","City":"null","CompanyID":25,"CompanyName":"Priya agency","CreatedBy":138,"CreatedDate":"19-06-2015 11:01:41","Email":"poombavai@gmail.com","IsActive":true,"LandLine":"06654-3422412","MobileNumber1":"9568678567","ModifiedBy":138,"PinCode":643434,"Remarks":"null","TonnageKM":"122","Website":"www.poombavai.com"}}.to_json, :content_type => "application/json"
我正在尝试使用 RestClient post 值。它总是显示以下错误。
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,"PinCode":0,"Remarks":"null","State":"null","TonnageKM":"0","TotalInsurableGoodValueForPreviousYear":0.00,"TotalInsurableGoodValuePerYear":0.00,"TotalTransportationCostForPreviousYear":0.00,"TotalTransportationCostPerYear":0.00,"TotalTransportedWeightPerYear":0.00,"Website":"null"}}, headers: {"Content-Type" => "application/json"}
这只是一个虚拟数据。 请帮忙。提前致谢。
终于解决了。格式有误。正确的格式是
response = RestClient.post "http://192.72.114.66/WDSTEST_WS/WDS_SERVICE.svc/companymaster/Add", {"CompanyMaster": {"Address1":"Ganapathy","Address2":"Coimbatore","BussinessProfile":"null","City":"null","CompanyID":25,"CompanyName":"Priya agency","CreatedBy":138,"CreatedDate":"19-06-2015 11:01:41","Email":"poombavai@gmail.com","IsActive":true,"LandLine":"06654-3422412","MobileNumber1":"9568678567","ModifiedBy":138,"PinCode":643434,"Remarks":"null","TonnageKM":"122","Website":"www.poombavai.com"}}.to_json, :content_type => "application/json"