-
1
- #1
I am trying to get PDF from via API but when in command restrequest.Execute happens then program crashes with error:
No mapping for the Unicode character exists in the target multi-byte code page.
Does anybody have any idea what is wrong it?
This works with postman so problem must be in my delphi code.
RESTClientx := TRESTClient.Create(nil);
restclientx.AcceptCharset := 'uft-8, *;q=0.8';
restclientx.ContentType := 'application/x- restclientx.FallbackCharsetEncoding := 'raw';
restclientx.BaseURL := '
RESTResponsex := TRESTResponse.Create(nil);
RESTRequestx:= TRESTRequest.Create(nil);
restrequestx.Client := RESTClientx;
RESTRequestx.Method := rmpost;
RESTRequestx.Params.Clear;
RESTRequestx.ClearBody;
RESTRequestx.Params.AddItem;
RESTRequestx.Params.Items[0].Kind := pkHTTPHEADER;
RESTRequestx.Params.Items[0].name := 'username';
RESTRequestx.Params.Items[0].Value := 'xxxxxxx';
RESTRequestx.Params.Items[0].Options := [poDoNotEncode];
RESTRequestx.Params.AddItem;
RESTRequestx.Params.Items[1].Kind := pkHTTPHEADER;
RESTRequestx.Params.Items[1].name := 'password';
RESTRequestx.Params.Items[1].Value := 'xxxxxxxx';
RESTRequestx.Params.Items[1].Options := [poDoNotEncode];
RESTRequestx.Params.AddItem;
RESTRequestx.Params.Items[2].Kind := pkHTTPHEADER;
RESTRequestx.Params.Items[2].name := 'parcels';
RESTRequestx.Params.Items[2].Value := '01234567890';
RESTRequestx.Params.Items[2].Options := [poDoNotEncode];
RESTRequestx.Params.AddItem;
RESTRequestx.Params.Items[3].Kind := pkHTTPHEADER;
RESTRequestx.Params.Items[3].name := 'printType';
RESTRequestx.Params.Items[3].Value := 'pdf';
RESTRequestx.Params.Items[3].Options := [poDoNotEncode];
restrequestx.Execute; <- this will cause error
No mapping for the Unicode character exists in the target multi-byte code page.
Does anybody have any idea what is wrong it?
This works with postman so problem must be in my delphi code.
RESTClientx := TRESTClient.Create(nil);
restclientx.AcceptCharset := 'uft-8, *;q=0.8';
restclientx.ContentType := 'application/x- restclientx.FallbackCharsetEncoding := 'raw';
restclientx.BaseURL := '
RESTResponsex := TRESTResponse.Create(nil);
RESTRequestx:= TRESTRequest.Create(nil);
restrequestx.Client := RESTClientx;
RESTRequestx.Method := rmpost;
RESTRequestx.Params.Clear;
RESTRequestx.ClearBody;
RESTRequestx.Params.AddItem;
RESTRequestx.Params.Items[0].Kind := pkHTTPHEADER;
RESTRequestx.Params.Items[0].name := 'username';
RESTRequestx.Params.Items[0].Value := 'xxxxxxx';
RESTRequestx.Params.Items[0].Options := [poDoNotEncode];
RESTRequestx.Params.AddItem;
RESTRequestx.Params.Items[1].Kind := pkHTTPHEADER;
RESTRequestx.Params.Items[1].name := 'password';
RESTRequestx.Params.Items[1].Value := 'xxxxxxxx';
RESTRequestx.Params.Items[1].Options := [poDoNotEncode];
RESTRequestx.Params.AddItem;
RESTRequestx.Params.Items[2].Kind := pkHTTPHEADER;
RESTRequestx.Params.Items[2].name := 'parcels';
RESTRequestx.Params.Items[2].Value := '01234567890';
RESTRequestx.Params.Items[2].Options := [poDoNotEncode];
RESTRequestx.Params.AddItem;
RESTRequestx.Params.Items[3].Kind := pkHTTPHEADER;
RESTRequestx.Params.Items[3].name := 'printType';
RESTRequestx.Params.Items[3].Value := 'pdf';
RESTRequestx.Params.Items[3].Options := [poDoNotEncode];
restrequestx.Execute; <- this will cause error