API input/process/set failing

Hi all,

Battling with automation here and not sure where I’m going wrong. I’ve created the input, created the feed and now coming to linking the two with a process to LOG the data and I just cannot get the api to do this.
Following the docs it should be:
Set input process list GET https://myweb.net/emoncms/input/process/set?inputid=0&processlist=0:0

However this fails with
{“success”:false,“message”:“Input processlist was not updated”}
I’ve tried crafting this is various ways, used post, get, json format, parameters (all including my apikey) and all return with this problem.
My alternative method:

    $jsonData = array(
    'processlist' => 'process__log_to_feed:100'
);
$jsonDataEncoded = json_encode($jsonData);
$dothis = file_get_contents('https://myweb.net/emoncms/input/process/set.json?inputid=10',null,stream_context_create(array(
    'http' => array(
        'protocol_version' => 1.1,
        'method'           => 'POST',
        'header'           => "Content-type: application/json\r\n".
                              "Connection: close\r\n" .
                              "Authorization: Bearer myapikey\r\n" .
                              "Content-length: " . strlen($jsonDataEncoded) . "\r\n",
        'content'          => $jsonDataEncoded,
    ),
)));

But same problem persists. I’ve also tried to capture the browser data, as when I do this with the GUI it works, it seems to post the same but there must be a magic key element I’m missing. Please help!

Thank you.
Andy

[Edited to format code snippet - RW]

Have you checked the emoncms logs? set log level to debug in settings.

You only need to ‘set’ the process list once, ever, not every time. Are you misunderstanding the set command? Is the processing set incorrectly?

Have you seen this Github issue relating to the input/process/set api?

1 Like

Sorry for the delay in replying. So yes I’m aware you set the process list once, it’s automatic scripting for when a new input is ‘discovered’ by my script and it adds the input and feed, the missing part is the process.
I hadn’t set log level up so that’s next step, thank you!

@pb66 yes I saw that and hence the code on my “alternative” method posted above which uses a POST using inputid in the get/url params and then the content being processlist.
I think there is a bug somewhere but cannot quite put my finger on it at the moment.
For now I’ve solved the issue by writing the value to the MySQL database:

$doupd=mysqli_query($link, "update input set processList='1:".$read_feed["id"]."' where id='".$in_id."' limit 1");

Which is working. I’ll keep trying to diagnose the error in the API however.

1 Like