You need to sign in to do that
Don't have an account?
NHK
Continuation Error: StatusCode=400
Hi All,
I am using Continuation for a callout in a VF page. I am getting a blank response body with StatusCode=400 . When i call the same service using normal HttpRequest, i am getting the proper response. Did any one came across a similar situation? Please help me resolve this error.
Best,
NHK
I am using Continuation for a callout in a VF page. I am getting a blank response body with StatusCode=400 . When i call the same service using normal HttpRequest, i am getting the proper response. Did any one came across a similar situation? Please help me resolve this error.
public object startLandAServiceRequest(){ Continuation con = new Continuation(60); try{ con.continuationMethod = 'processResponse'; HttpRequest request = new HttpRequest(); request.setMethod('GET'); request.setEndpoint('xxxx'); request.setClientCertificateName('xxxx'); request.setHeader('Content-type','text/xml'); request.setBody('xxxx'); this.requestLabel = con.addHttpRequest(request); }catch(Exception e){ isError = true; errorString = e.getMessage(); System.debug(e.getStackTraceString()); } return con; } public object processResponse(){ HttpResponse response = Continuation.getResponse(this.requestLabel); result = response.getBody(); return null; }
Best,
NHK
Status code 400 implies that the external system could not understand your request. It considers as bad.
Generally GET method does not require a body as part of the request. I would advice you to try without body and content-type header.
Also, please paste the code you use to call the service using http GET method.
Good luck.
Please find below the code for Normal Http Request. In buildHeader and buildBody methods i am actually building the request body in order to pass the security token and other information which is mandatory for the user identification by the endpoint.
The limitation with Apex Continuations is regarding Named Credentials.
Presently, Named Credentials work only with regular Apex callouts. To use a client certificate in an Apex continuation, a regular Remote Site Setting URL needs to be used, and the client certificate can be set in the HttpRequest's properties either by developer name or by a base64 string of a PKCS#12 file plus that PKCS#12 file's password.
Named Credentials are somewhat new, though they have been around for several releases. Named Credentials offer a convenient way to specify the client certificate and any HTTP-level authentication within a Named Credential configuration, and Apex code can make use of that configuration by referencing the named credential in the callout URL. That feature, however, doesn't yet work with Apex Continuation callouts.