question

Upvotes
Accepted
1 2 3 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 512.0 KiB each and 1.0 MiB total.

Thank you for your participation in the forum.

Are any of the replies below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the most appropriate reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,
AHS

Thank you for your participation in the forum.

Are any of the replies below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the most appropriate reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,
AHS

Upvote
Accepted
1.5k 5 6 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 512.0 KiB each and 1.0 MiB total.

Upvotes
36 11 10 23

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 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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