question

dolfin1986 avatar image
dolfin1986 asked dolfin1986 answered

Problem printing to Clover device from Remote-pay-cloud-pos-react example

Hi,

I have installed Remote-pay-cloud-pos-react example connecting to Flex DevKit using sandbox account. POS is working fine with exception of Print. Not able to print neither Text nor Image from the Device Tab in the example GUI. MacOS (ver 11.5.2), Chrome Version 94.0.4606.61. This is my code (slightly changed example thinking that missing set of request id matter):

printerChosen(printer, printType){ // executes print job based on type selected
if(printType === 'URL’){
...}
else if(printType === 'TEXT'){
let pr = new clover.sdk.remotepay.PrintRequest();
pr.setText([this.state.printTextContent]);
pr.setPrintDeviceId(printer.id);
pr.setPrintRequestId('112233');
pr.setRequestId('2112233');
console.log('PrintRequest - Print Text', pr);
this.cloverConnector.print(pr);
}

Request:

  1. imageUrls: undefined
  2. images: undefined
  3. printDeviceIdi: "ZYD88X3B0C1D2"
  4. printRequestId: "112233"
  5. requestId: "2112233"
  6. text: ['Print This!!']
  7. version: undefined

Response:

  1. cause: undefined
  2. code: "UnknownError"
  3. message: "{\"method\":\"REMOTE_ERROR\",\"version\":1,\"errorDetail\":\"com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at path $.textLines\\n\\tat com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)\\n\\tat com.google.gson.Gson.fromJson(Gson.java:932)\\n\\tat com.google.gson.Gson.fromJson(Gson.java:1003)\\n\\tat com.google.gson.Gson.fromJson(Gson.java:975)\\n\\tat com.clover.remote.message.Message.fromJsonObject(Message.java:97)\\n\\tat com.clover.remote.message.Message.fromJsonString(Message.java:92)\\n\\tat com.clover.remote.terminal.shared.Payload.getMessage(Payload.java:61)\\n\\tat com.clover.remote.terminal.shared.handler.KioskInboundHandler.getMessage(KioskInboundHandler.java:66)\\n\\tat com.clover.remote.terminal.shared.handler.inbound.PrintTextHandler.decode(PrintTextHandler.java:31)\\n\\tat com.clover.remote.terminal.shared.handler.inbound.PrintTextHandler.decode(PrintTextHandler.java:12)\\n\\tat com.clover.remote.terminal.lib.KioskMessageControlService.sendToKiosk(KioskMessageControlService.java:132)\\n\\tat com.clover.remote.terminal.lib.KioskMessageControlService.onMessage(KioskMessageControlService.java:118)\\n\\tat com.clover.remote.terminal.lib.KioskMessageControlService.lambda$onMessage$0$KioskMessageControlService(KioskMessageControlService.java:102)\\n\\tat com.clover.remote.terminal.lib.-$$Lambda$KioskMessageControlService$168hxTUCFZomxURRSH0F0KAX-5g.run(Unknown Source:4)\\n\\tat android.os.Handler.handleCallback(Handler.java:883)\\n\\tat android.os.Handler.dispatchMessage(Handler.java:100)\\n\\tat android.os.Looper.loop(Looper.java:214)\\n\\tat android.app.ActivityThread.main(ActivityThread.java:7397)\\n\\tat java.lang.reflect.Method.invoke(Native Method)\\n\\tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)\\n\\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)\\nCaused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at path $.textLines\\n\\tat com.google.gson.internal.bind.JsonTreeReader.expect(JsonTreeReader.java:163)\\n\\tat com.google.gson.internal.bind.JsonTreeReader.beginArray(JsonTreeReader.java:72)\\n\\tat com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:80)\\n\\tat com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)\\n\\tat com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)\\n\\tat com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)\\n\\t... 20 more\\n\",\"errorMessage\":\"Error processing message - PRINT_TEXT\"}"
  4. type: "EXCEPTION"

Any help is appreciated very much.

remote pay java
10 |2000

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

dolfin1986 avatar image
dolfin1986 answered

This is in the Example provided by Clover... Seems to be aligned with specs:

(static) PrintRequest#setText(text)

Set the field value The text to be printed.
Parameters:NameTypeDescription textArray.<String>An array of


I have no problem to set it as string if this is the issue...

10 |2000

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

dolfin1986 avatar image
dolfin1986 answered

I can not print image either with similar error message. Please note that for printing images arrays are also used with the comment: "(put in an array for future extensibility)". I believe set for text is consistent so array of strings is a parameter.

10 |2000

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

David Marginian avatar image
David Marginian Deactivated answered

I can't reproduce this issue. Please make sure you:

1) Have the latest examples pulled.

2) If you have a package-lock.json file, remove it.

3) Remove your node_modules directory

4) Run 'npm install && npm build'

10 |2000

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

dolfin1986 avatar image
dolfin1986 answered

Thank you very much, it is working now!

10 |2000

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

Welcome to the
Clover Developer Community