0

I have this code on my node.js server (Google's App Engine):

    const formattedName = iotClient.devicePath(projectId, cloudRegion, registryId, numSerie)    
    const binaryData = Buffer.from(command);            
    const request = {
        name: formattedName,
        binaryData: binaryData,
    };
    try {
        const responses = await iotClient.sendCommandToDevice(request);
        res.send(responses[0])
    } catch (err) {
        res.send(err)
    }
    }

And this on my front end (angular 9 - GET):

 this.httpClient.get('https://XXXXXXXX.appspot.com/?numSerie=' + 'DOCID' + '&proyecto=XXXX&registro=XXXX&region=XXXX&command=' + JSON.stringify(jsonEnviar));

Everthing works perfect if I send commands as numbers, 1-20, for example. However if I want to send a JSON it fails, my device won't get the command. Any idea why?

1x2x3x4x
  • 592
  • 8
  • 26
  • Do you need to URL encode the resulting string returned from JSON.stringify ... https://stackoverflow.com/questions/6554039/how-do-i-url-encode-something-in-node-js – Kolban May 18 '20 at 18:37
  • I encode it like this encodeURIComponent(JSON.stringify(jsonEnviar))) and decode it in node but still nothing. – 1x2x3x4x May 19 '20 at 06:33

0 Answers0