question

Upvotes
Accepted
1 1 2 5

TRKD API: getToken does not work

  1. In Client Sample code : TRKD API On page 1030 , HttpsAndAnonymous_MetroClient class, I got response object back.

    But when I try to print token using command ‘response.getToken()’, it gives junk characters. ( Real token appears in SOAP message).

    Can you please advise why response.getToken() does print garbage chars and not token as appeared in SOAP message?

    System.out.println("Token byte[]: "+ response.getToken()); // I tried with different CHARSET e.g.UTF-8 etc.. but no luck.

    Let me know if my questions are not clear enough.

    Any help is appreciated.

rkd-apirkd
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvote
Accepted
1.5k 3 5 7

Your question is really related to Java, not to the TRKD API as such.

If the response.getToken() method returns byte[] then you really cannot print like that. Try Arrays.toString() or DatatypeConverter.printHexBinary() before attempting to display.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
36 6 8 22

Try this.

byte[] bytes = authorizationtype.getToken();

String token = new BASE64Encoder().encode(bytes);

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea