Forum > Networking and Web Programming

[Solved] Access violation using Post method with TFPHTTPClient

(1/1)

BlueIcaro:
Hello I have the following code:

--- Code: --- PeticionHttp.RequestHeaders.Clear;
  PeticionHttp.AddHeader('Content-Type', 'application/x-www-form-urlencoded;v=2.0');
  PeticionHttp.AddHeader('Accept', 'application/hal+json;v=2.0');
  Respuesta := TStringList.Create();
  BodyText := 'resources=1';//&1=/rw/iosystem/signals/ethernet/board1/do0&1-P=0';
  PeticionHttp.RequestBody.WriteAnsiString('resources:1');
  PeticionHttp.RequestBody.WriteAnsiString(
    '1=/rw/iosystem/signals/ethernet/board1/do0;state');
  PeticionHttp.RequestBody.WriteAnsiString('1-P=0');
  PeticionHttp.RequestBody.Position:=0;
  PeticionHttp.Post('https://localhost:80/subscription', Respuesta);           

--- End code ---
I got a access violation in this line:

--- Code: ---PeticionHttp.RequestBody.WriteAnsiString('resources=1'); 

--- End code ---

I using Lazarus 3.0 and FPC 3.3.1 Trunc

Any idea?

Thanks

/BlueIcaro

BlueIcaro:
Hello, I found the problem.
I missed this line:

--- Code: ---  PeticionHttp.RequestBody:=TRawByteStringStream.Create;   

--- End code ---

/BlueIcaro

Navigation

[0] Message Index

Go to full version