Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. var credentials = {
  2. username: 'bunnyman',
  3. password: '*******'
  4. };
  5.  
  6. // Stuff the cookie into a global (for now)
  7. var cookie;
  8.  
  9. request.post({
  10. uri: the_uri_of_the_login_api,
  11. headers: { 'content-type': 'application/json' },
  12. json: credentials
  13. }, function(err, res, body){
  14. if(err) {
  15. console.log("error", body);
  16. } else {
  17. cookie = body;
  18. }
  19. });
  20.  
  21. var query = {
  22. "input": { "some_form_property": "value" },
  23. "additionalInput": {
  24. "8d817939-your-api-key-f5dc9502ed72": cookie
  25. },
  26. "returnPaginationSuggestions": true
  27. }
  28. request.post({
  29. uri: the_uri_of_the_query_api,
  30. headers: { 'content-type': 'application/json' },
  31. json: query
  32. }, function (error, response, payload){
  33. if (error){
  34. console.log(payload);
  35. } else {
  36. console.log(payload);
  37. }
  38. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement