How to use the request.put function in request

To help you get started, we’ve selected a few request examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apollographql / graphql-tools / src / tracing.js View on Github external
sendReport(report) {
    request.put({
      url: 'https://nim-test-ingress.appspot.com',
      json: report,
    }, (err) => {
      if (err) {
        console.log('err', err);
        return;
      }
      // console.log('status', response.statusCode);
    });
  }
github likeastore / app / test / api / feed.spec.js View on Github external
function putToCollection(item, callback) {
						request.put({url: testUtils.getRootUrl() + '/api/collections/' + firstCollection._id + '/items/' + item._id, headers: secondUserHeaders}, callback);
					}
				});
github lonhutt / mlrepl / mlrepl.js View on Github external
updateDb: function(dbname){
    console.log("please wait for the server config to finished updating")
    request.put('http://localhost:8002/manage/v2/servers/repl-http/properties?group-id=Default', 
        {
          auth: {user:this.user, pass:this.password, sendImmediately:false},
          json: {'content-database':dbname},
          scope: this
        }, 
        function(err,resp, body){
          if(err){
            console.log(err);
          } else {
            this.scope.database = dbname;
            console.log(body);
          }
          
      });
  },
  fetchConfig: function(init){
github hevans90 / oa3-api-defender / src / endpoint-validator.ts View on Github external
headers: headers ? headers : undefined,
          },
          (err: any, res: request.Response) => {
            this.verifyRequest(
              err,
              res,
              'delete',
              paramaterisedPath,
              validateFn,
            );
          },
        );
        break;
      }
      case 'put': {
        request.put(
          {
            url: `${rootUrl}${paramaterisedPath}`,
            headers: headers ? headers : undefined,
            body: body ? body : undefined,
            json: true,
          },
          (err: any, res: request.Response) => {
            this.verifyRequest(err, res, 'put', paramaterisedPath, validateFn);
          },
        );
        break;
      }
      case 'patch': {
        request.patch(
          {
            url: `${rootUrl}${paramaterisedPath}`,
github LockerProject / Locker / Ops / registry.js View on Github external
function adduser (username, password, email, cb) {
  if (password.indexOf(":") !== -1) return cb(new Error(
    "Sorry, ':' chars are not allowed in passwords.\n"+
    "See  for why."));
  var salt = "na"
    , userobj = {name : username
               , salt : salt
               , password_sha : crypto.createHash("sha1").update(password+salt).digest("hex")
               , email : email
               , _id : 'org.couchdb.user:'+username
               , type : "user"
               , roles : []
               , date: new Date().toISOString()};
      logger.info("adding user "+JSON.stringify(userobj));
  request.put({uri:regBase+'/-/user/org.couchdb.user:'+encodeURIComponent(username), json:true, body:userobj}, cb);
}
github slanatech / swagger-stats / lib / swsElasticEmitter.js View on Github external
}else {

            var initializeNeeded = false;

            if(response.statusCode === 404){
                initializeNeeded = true;
            }else if(response.statusCode === 200){
                if( 'template_api' in body ) {
                    if (!('version' in body.template_api) || (body.template_api.version < requiredTemplateVersion)) {
                        initializeNeeded = true;
                    }
                }
            }

            if(initializeNeeded){
                request.put(putOptions, function (error, response, body) {
                    if(error) {
                        debug("Failed to update template:", JSON.stringify(error));
                    }
                });
            }

        }
    });
github grayleonard / node-youtube-resumable-upload / index.js View on Github external
resumableUpload.prototype.getProgress = function(handler) {
	var self = this;
	var options = {
		url: self.location,
		headers: {
		  'Authorization':	'Bearer ' + self.tokens.access_token,
		  'Content-Length':	0,
		  'Content-Range':	'bytes */' + fs.statSync(self.filepath).size
		}
	};
	request.put(options, handler);
}
github OfficeDev / microsoft-teams-sample-complete-node / src / apis / ExampleOAuth1API.ts View on Github external
err.statusMessage = http.STATUS_CODES[response.statusCode];
            }

            callback(err, body);
        };

        switch (method.toLowerCase())
        {
            case "get":
                request.get(options, requestCallback);
                break;
            case "post":
                request.post(options, requestCallback);
                break;
            case "put":
                request.put(options, requestCallback);
                break;
            case "delete":
                request.delete(options, requestCallback);
                break;
        }
    };
github DinoChiesa / apigee-edge-js / lib / resourcefile.js View on Github external
}
      let afterUpdate =
        function(e, result) {
          if (conn.verbosity>0) {
            if (e) {
              utility.logWrite('Update error: ' + JSON.stringify(e));
            }
            else {
              utility.logWrite('Update result: ' + JSON.stringify(result));
            }
          }
          return cb(e, result);
        };

      fs.createReadStream(options.filename)
        .pipe(request.put(requestOptions, common.callback(conn, [200], afterUpdate)));
    });
  }
github kenodressel / lieferheld-api / order-api.js View on Github external
return new Promise(function (resolve, reject) {
        request
            .put({
                'url': c.url + '/users/' + order.general.user_id + '/orders/' + order.id + '/',
                headers: {
                    'authentication': auth.getAuth(),
                    "Content-Type": "application/json"
                },
                body: JSON.stringify(order)
            }, helper.handleResponse(resolve, reject));
    });
};