2016-09-06 7 views
0

RestClient를 사용하여 값을 게시하려고합니다. 항상 다음 오류를 표시합니다.Rails를 사용하는 RestClient의 POST 메서드

위해 RESTClient : BadRequest (400 잘못된 요청) :

SO의 모든 답변을 시도했다. 아무것도 도움이되지 않았습니다. 이것은 내 코드입니다.

응답 = RestClient.post "http://192.72.114.66/WDSTEST_WS/WDS_SERVICE.svc/companymaster/Add", { "CompanyMaster": { "주소 1": "라자 거리 CBE", "BussinessProfile": "평생 학습", "도시" "statee", "회사 ID를" : 24, "CompanyName": "Ramu Metall", "CreatedBy": 138, "Email": "[email protected]", "IsActive": true, "LandLine": "435435", "MobileNumber1": "8787871221 ","ModifiedBy ": 138,"PinCode ": 0,"비고 ":"null ","State ":"null ","TonnageKM ":"0 ","TotalInsurableGoodValueForPreviousYear ": 0.00,"TotalInsurableGoodValuePerYear " "TotalTransportationCostForPreviousYear"0.00 "TotalTransportationCostPerYear"0.00 "TotalTransportedWeightPerYear"0.00, "웹 사이트": "널 (null)"}} 헤더 : { "의 Content-Type"=> "응용 프로그램/JSON"}

,

이것은 단지 더미 데이터입니다. 도와주세요. 미리 감사드립니다.

답변

1

마지막으로 해결했습니다. 형식이 잘못되었습니다. 올바른 형식은

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":"[email protected]","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" 
+0

다행입니다. 이 답변을 "수락 됨"으로 표시하면 모든 설정을 알 수 있습니다. – alberge