HttpWebReq := HttpWebReq.CreateHttp('https://intapppreprod2com/security/createJWTToken'); HttpWebReq.Timeout := 300000; HttpWebReq.Accept := 'application/json'; HttpWebReq.ContentType := 'application/json'; //HttpWebReq.Credentials := Credential.NetworkCredential('Authorization','Basic '+'aW378dgwgfiuweffhoefhK'); Credential :=Credentials.NetworkCredential('Authorization','Basic '+'aW378dgwgfiuweffhoefhK'); HttpWebReq.Credentials := Credentials; HttpWebReq.Method := 'POST'; ServicePointManager.SecurityProtocol(SecurityProtocol.Tls12); HttpWebReq.UseDefaultCredentials(FALSE); StreamWriter := StreamWriter.StreamWriter(HttpWebReq.GetRequestStream,Encoding.GetEncoding('utf-8')); BearerTokenRequest := '{"username":' + '"'+'cdnnator'+'",'+'"password":'+'"'+'123test'+'",'+'"sellerCode":'+'"'+'124657'+'","callerName":'+'"'+'test"'+'}'; MESSAGE(BearerTokenRequest); StreamWriter.Write(BearerTokenRequest); StreamWriter.Close; HttpWebResp := HttpWebReq.GetResponse;//(Error part) TempBlob.INIT; TempBlob.Blob.CREATEINSTREAM(ResponseInStream); HttpWebResp.GetResponseStream.CopyTo(ResponseInStream); HttpStatusCode := HttpWebResp.StatusCode; ResponseHeaders := HttpWebResp.Headers; ResponseInStream.READ(ResponseText); //ResponseToken := COPYSTR(ResponseText,STRPOS(ResponseText,'access_token')+STRLEN('access_token')+3,328); ResponseToken := COPYSTR(ResponseText,STRPOS(ResponseText,'access_token')+STRLEN('access_token')+3,STRPOS(ResponseText,',"token_type"')-19); MESSAGE(ResponseToken); MESSAGE('%1',ResponseText); EXIT(ResponseToken);
Answers
HttpWebReq.Headers.Add('Authorization','Basic '+'aW378dgwgfiuweffhoefhK');
HttpWebReq.Headers.Add (Correct)=A Capital
HttpWebReq.Headers.add (Wrong) = a small
I Try to use for the first time.
Can you explain me your code.
I need to do a POST with authentification basic and two parameters in my body, one string and one file.
Thank you for your help.