我使用下面的代码发送带有json请求正文的http发布请求,我得到400 status = null,但是在尝试使用邮递员时,我得到了状态码500,这意味着至少它命中了服务器。
尝试使用具有相同请求正文的邮递员,并获取状态码500,这至少意味着其到达服务器。
String reqbodydata = '{"TUCANREL4": "<TUCANREL4><Route RouteDest=\"Canada\" RouteType=\"Test\" /><UserReference>TEST</UserReference><MemberCode>ZZ97519832</MemberCode><Password>MICH</Password><Product>07000</Product><TTY><FFR>Y</FFR><Language>English</Language></TTY><Subject><Name><LastName>Isabell</LastName><FirstName>Fernando</FirstName></Name><DOB>19550825</DOB><Address><Civic>170</Civic><Street>Jackson St. E.</Street><City>Hamilton</City><Postal>L8N1L4</Postal><Prov>ON</Prov><Telephone>9053185555</Telephone></Address></Subject><OptionalRequest><OwningBureau>Y</OwningBureau><ErrorText>B</ErrorText><TradeMop>Y</TradeMop><Summary>Y</Summary></OptionalRequest></TUCANREL4>","birthDate": "1955-08-25","employmentTypeCode": "FullTime","financialConditionCode": "BK","dependentsCount": 0,"maritalStatusCode": "Married","homeOwnerInd": true,"monthlyRentPaymentAmount": 1,"totalOtherMonthlyExpensesAmount": 1,"monthsEmployed": 1,"grossMonthlyIncomeAmount": 1,"politicallyExposedInd": true,"otherBeneficiaryInd": true}';
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('https://paschidev-api-bdm-canaccede-fidemcc.azurewebsites.net/default');
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json;charset=UTF-8');
system.debug('Checkreq01' + reqbodydata);
req.setBody(reqbodydata);
req.setCompressed(true); // otherwise we hit a limit of 32000
try {
system.debug('Checkreq' + req.getBody());
res = http.send(req);
我正在使用的请求正文:
{
"TUCANREL4": "<TUCANREL4><Route RouteDest=\"Canada\" RouteType=\"Test\" /><UserReference>TEST</UserReference><MemberCode>ZZ97519832</MemberCode><Password>MICH</Password><Product>07000</Product><TTY><FFR>Y</FFR><Language>English</Language></TTY><Subject><Name><LastName>Isabell</LastName><FirstName>Fernando</FirstName></Name><DOB>19550825</DOB><Address><Civic>170</Civic><Street>Jackson St. E.</Street><City>Hamilton</City><Postal>L8N1L4</Postal><Prov>ON</Prov><Telephone>9053185555</Telephone></Address></Subject><OptionalRequest><OwningBureau>Y</OwningBureau><ErrorText>B</ErrorText><TradeMop>Y</TradeMop><Summary>Y</Summary></OptionalRequest></TUCANREL4>",
"birthDate": "1955-08-25",
"employmentTypeCode": "FullTime",
"financialConditionCode": "BK",
"dependentsCount": 0,
"maritalStatusCode": "Married",
"homeOwnerInd": true,
"monthlyRentPaymentAmount": 1,
"totalOtherMonthlyExpensesAmount": 1,
"monthsEmployed": 1,
"grossMonthlyIncomeAmount": 1,
"politicallyExposedInd": true,
"otherBeneficiaryInd": true
}
预期的输出应为:尖顶回应时,状态码为500,如来自邮递员,请提出建议。