Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread basic authorization
Wed, Jan 25 2017 7:03 PMPermanent Link

KimHJ

Comca Systems, Inc

I have a printer that send http Post to a web-server to see if there is any print jobs. In the printers webpage I can enter the URL, Login and password. From the documentation it say it use basic authorization. How can I retrieve the Login and Password in the EWB Module?
I tried to enter it in the URL but I receive the same Json regardless.

Thanks,
Kim
Wed, Jan 25 2017 7:56 PMPermanent Link

Raul

Team Elevate Team Elevate

On 1/25/2017 7:03 PM, KimHJ wrote:
> I have a printer that send http Post to a web-server to see if there is any print jobs. In the printers webpage I can enter the URL, Login and password. From the documentation it say it use basic authorization. How can I retrieve the Login and Password in the EWB Module?
> I tried to enter it in the URL but I receive the same Json regardless.

If you're acting as a server then you need to look for the
"Authorization:" header (this should be in RequestHeaders of the
TEWBServerRequest object).

Value would have word Basic on it followed by base64 encoded value of
usernameTonguessword (appended together with : as separator)

For example your might see something like this :

Authorization: Basic VXNlcm5hbWU6UGFzc3dvcmQ=

The other option is for them to be included in the URL but i assume
you've checked that already.

Raul
Wed, Jan 25 2017 9:14 PMPermanent Link

KimHJ

Comca Systems, Inc

>>Raul wrote:

>>If you're acting as a server then you need to look for the
>>"Authorization:" header (this should be in RequestHeaders of the
>>TEWBServerRequest object).

This is what is in the Request.RequestContent:

{
   "status": "23 6 0 0 0 0 0 0 0 ",
   "printerId": "1000",
   "userInterval": 30,
}

Another thing, I have tried for hours to get the "printerid" value but the LJsonObj always return nil. Do you know of another way to get the value?

LJsonObj  : TJSONObject;
StoreId: TJSONValue;
TempStr, MyPrinterId: String;

TempStr :=  := Request.RequestContent;
LJsonObj := TJSONObject.ParseJSONValue(TempStr ) as TJSONObject;
if LJsonObj <> nil then
  begin
          StoreId:=LJsonObj.Get('printerId').JsonValue;
          MyPrinterId:=StoreId.Value;
  end;

Thanks
Wed, Jan 25 2017 9:26 PMPermanent Link

KimHJ

Comca Systems, Inc

>>KimHJ wrote:

>>{
>>    "status": "23 6 0 0 0 0 0 0 0 ",
>>    "printerId": "1000",
>>    "userInterval": 30,
>>}

>>Another thing, I have tried for hours to get the "printerid" value but the LJsonObj always return nil. Do you know >>of another way to get the value?

Just found the problem why it is not parsing, there is a comma in the end after 30. That what happens when you trust that you receive a valid Json.
Image