Hi,
I am new to Apigee and I have what I presume is probably a newbie question, so please bear with me.
I have an incoming payload in a request body. The payload is a JSON array of elements that I want to PUT into a BaaS collection. I need to PUT each element, as the next time the payload is received, I want to overwrite the element if it is already there by "name" (businessKey in my sample code).
I started down the NodeJS route (see below) for my first go at it. However, I am facing a couple of issues and I have a couple of questions:
var express = require('express'); var usergrid = require('usergrid'); var config = require('./config'); var dataClient = new usergrid.client({ orgName: 'my-org', appName: 'MyAppName' }); var input_data = JSON.parse(context.getVariable("request.content")); for (var i = 0; i < input_data.length; i++) { var currentElement = input_data[i]; currentElement["name"] = currentElement.businessKey; var options = { endpoint: "mycollection/" + currentElement.name, method: "PUT", body: currentElement } dataClient.request(options, function (error, result) { // TODO if (error) { //error } else { //success } }); }
Any help/guidance would be greatly appreciated,
Simon
Hi @Simon Pink my answers are in order of your questions:
Let us know if you have additional questions.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |