Advertisement
Guest User

API POST

a guest
Jul 25th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. /* This function is used to receive JSON information through an apikey, nonce and then a hmac sha512 signed message with an apisecret is send through a JSON POST request */
  2. function ImportJSONViaPost(url, payload, fetchOptions, query, parseOptions) {
  3. var postOptions = parseToObject_(fetchOptions);
  4.  
  5. if (postOptions["method"] == null) {
  6. postOptions["method"] = "POST";
  7. }
  8.  
  9. if (postOptions["payload"] == null) {
  10. postOptions["payload"] = payload;
  11. }
  12.  
  13. if (postOptions["contentType"] == null) {
  14. postOptions["contentType"] = "application/x-www-form-urlencoded";
  15. }
  16.  
  17. convertToBool_(postOptions, "validateHttpsCertificates");
  18. convertToBool_(postOptions, "useIntranet");
  19. convertToBool_(postOptions, "followRedirects");
  20. convertToBool_(postOptions, "muteHttpExceptions");
  21.  
  22. return ImportJSONAdvanced(url, postOptions, query, parseOptions, includeXPath_, defaultTransform_);
  23. }
  24.  
  25. function ImportJSONAdvanced(url, fetchOptions, query, parseOptions, includeFunc, transformFunc) {
  26. var jsondata = UrlFetchApp.fetch(url, fetchOptions);
  27. var object = JSON.parse(jsondata.getContentText());
  28.  
  29. return parseJSONObject_(object, query, parseOptions, includeFunc, transformFunc);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement