Mobiledevices: action missing












0














I am trying to perform a POST of the action, however, when I make the request I get code 400 speaking that the action value is missing.



my code:



function mobileAPIPOST() {

var response = UrlFetchApp.fetch(
"https://www.googleapis.com/admin/directory/v1/customer/my_customer/devices/mobile/fakexQ_fake0Z0dKFdSblfakeTnnfakel7IYwixfake4ddZfakeAIvnmu/action", {
method: "POST",
headers: {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
"Content-Type": "application/json",
},
data: {
"action": "block"
},
muteHttpExceptions: true
});

}


I updated the code following the response from @TheMaster.



My updated code:



function mobileAPIPOST() {

var response = UrlFetchApp.fetch(
"https://www.googleapis.com/admin/directory/v1/customer/my_customer/devices/mobile/fakexQ_fake0Z0dKFdSblfakeTnnfakel7IYwixfake4ddZfakeAIvnmu/action", {
method: "POST",
headers: {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
"Content-Type": "application/json",
},
payload: {
"action": "block"
},
muteHttpExceptions: true
});

}


error pointed out:



{
"error": {
"errors": [
{
"domain": "global",
"reason": "parseError",
"message": "Parse Error"
}
],
"code": 400,
"message": "Parse Error"
}
}









share|improve this question
























  • Use JSON.stringify(payload) as shown in the reference
    – TheMaster
    Nov 21 '18 at 16:50
















0














I am trying to perform a POST of the action, however, when I make the request I get code 400 speaking that the action value is missing.



my code:



function mobileAPIPOST() {

var response = UrlFetchApp.fetch(
"https://www.googleapis.com/admin/directory/v1/customer/my_customer/devices/mobile/fakexQ_fake0Z0dKFdSblfakeTnnfakel7IYwixfake4ddZfakeAIvnmu/action", {
method: "POST",
headers: {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
"Content-Type": "application/json",
},
data: {
"action": "block"
},
muteHttpExceptions: true
});

}


I updated the code following the response from @TheMaster.



My updated code:



function mobileAPIPOST() {

var response = UrlFetchApp.fetch(
"https://www.googleapis.com/admin/directory/v1/customer/my_customer/devices/mobile/fakexQ_fake0Z0dKFdSblfakeTnnfakel7IYwixfake4ddZfakeAIvnmu/action", {
method: "POST",
headers: {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
"Content-Type": "application/json",
},
payload: {
"action": "block"
},
muteHttpExceptions: true
});

}


error pointed out:



{
"error": {
"errors": [
{
"domain": "global",
"reason": "parseError",
"message": "Parse Error"
}
],
"code": 400,
"message": "Parse Error"
}
}









share|improve this question
























  • Use JSON.stringify(payload) as shown in the reference
    – TheMaster
    Nov 21 '18 at 16:50














0












0








0







I am trying to perform a POST of the action, however, when I make the request I get code 400 speaking that the action value is missing.



my code:



function mobileAPIPOST() {

var response = UrlFetchApp.fetch(
"https://www.googleapis.com/admin/directory/v1/customer/my_customer/devices/mobile/fakexQ_fake0Z0dKFdSblfakeTnnfakel7IYwixfake4ddZfakeAIvnmu/action", {
method: "POST",
headers: {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
"Content-Type": "application/json",
},
data: {
"action": "block"
},
muteHttpExceptions: true
});

}


I updated the code following the response from @TheMaster.



My updated code:



function mobileAPIPOST() {

var response = UrlFetchApp.fetch(
"https://www.googleapis.com/admin/directory/v1/customer/my_customer/devices/mobile/fakexQ_fake0Z0dKFdSblfakeTnnfakel7IYwixfake4ddZfakeAIvnmu/action", {
method: "POST",
headers: {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
"Content-Type": "application/json",
},
payload: {
"action": "block"
},
muteHttpExceptions: true
});

}


error pointed out:



{
"error": {
"errors": [
{
"domain": "global",
"reason": "parseError",
"message": "Parse Error"
}
],
"code": 400,
"message": "Parse Error"
}
}









share|improve this question















I am trying to perform a POST of the action, however, when I make the request I get code 400 speaking that the action value is missing.



my code:



function mobileAPIPOST() {

var response = UrlFetchApp.fetch(
"https://www.googleapis.com/admin/directory/v1/customer/my_customer/devices/mobile/fakexQ_fake0Z0dKFdSblfakeTnnfakel7IYwixfake4ddZfakeAIvnmu/action", {
method: "POST",
headers: {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
"Content-Type": "application/json",
},
data: {
"action": "block"
},
muteHttpExceptions: true
});

}


I updated the code following the response from @TheMaster.



My updated code:



function mobileAPIPOST() {

var response = UrlFetchApp.fetch(
"https://www.googleapis.com/admin/directory/v1/customer/my_customer/devices/mobile/fakexQ_fake0Z0dKFdSblfakeTnnfakel7IYwixfake4ddZfakeAIvnmu/action", {
method: "POST",
headers: {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
"Content-Type": "application/json",
},
payload: {
"action": "block"
},
muteHttpExceptions: true
});

}


error pointed out:



{
"error": {
"errors": [
{
"domain": "global",
"reason": "parseError",
"message": "Parse Error"
}
],
"code": 400,
"message": "Parse Error"
}
}






google-apps-script google-admin-sdk http-status-code-400






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 17:15

























asked Nov 21 '18 at 16:28









Leticia Fatima

195




195












  • Use JSON.stringify(payload) as shown in the reference
    – TheMaster
    Nov 21 '18 at 16:50


















  • Use JSON.stringify(payload) as shown in the reference
    – TheMaster
    Nov 21 '18 at 16:50
















Use JSON.stringify(payload) as shown in the reference
– TheMaster
Nov 21 '18 at 16:50




Use JSON.stringify(payload) as shown in the reference
– TheMaster
Nov 21 '18 at 16:50












1 Answer
1






active

oldest

votes


















1














UrlFetchApp doesn't have a data key parameter. Use payload instead.



Reference:



UrlFetchApp



Code Snippet:



UrlFetchApp.fetch(url,
{
method: "POST",
headers: {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
},
contentType: 'application/json',
payload: JSON.stringify({
"action": "block"
}),
muteHttpExceptions: true
});





share|improve this answer























  • when I use payload it points the error 'parse error'
    – Leticia Fatima
    Nov 21 '18 at 16:41










  • @Leticia Edit your question to show the new code and "Quote" the error
    – TheMaster
    Nov 21 '18 at 16:42










  • I added this to my code, I made the request and it returned the code 204. I made the get again, and the requested change in POST was not made.
    – Leticia Fatima
    Nov 21 '18 at 17:20










  • @Leticia Unclear. So, solved? What's the final code? Did the above work? Or did I miss something?
    – TheMaster
    Nov 21 '18 at 17:58













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416512%2fmobiledevices-action-missing%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














UrlFetchApp doesn't have a data key parameter. Use payload instead.



Reference:



UrlFetchApp



Code Snippet:



UrlFetchApp.fetch(url,
{
method: "POST",
headers: {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
},
contentType: 'application/json',
payload: JSON.stringify({
"action": "block"
}),
muteHttpExceptions: true
});





share|improve this answer























  • when I use payload it points the error 'parse error'
    – Leticia Fatima
    Nov 21 '18 at 16:41










  • @Leticia Edit your question to show the new code and "Quote" the error
    – TheMaster
    Nov 21 '18 at 16:42










  • I added this to my code, I made the request and it returned the code 204. I made the get again, and the requested change in POST was not made.
    – Leticia Fatima
    Nov 21 '18 at 17:20










  • @Leticia Unclear. So, solved? What's the final code? Did the above work? Or did I miss something?
    – TheMaster
    Nov 21 '18 at 17:58


















1














UrlFetchApp doesn't have a data key parameter. Use payload instead.



Reference:



UrlFetchApp



Code Snippet:



UrlFetchApp.fetch(url,
{
method: "POST",
headers: {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
},
contentType: 'application/json',
payload: JSON.stringify({
"action": "block"
}),
muteHttpExceptions: true
});





share|improve this answer























  • when I use payload it points the error 'parse error'
    – Leticia Fatima
    Nov 21 '18 at 16:41










  • @Leticia Edit your question to show the new code and "Quote" the error
    – TheMaster
    Nov 21 '18 at 16:42










  • I added this to my code, I made the request and it returned the code 204. I made the get again, and the requested change in POST was not made.
    – Leticia Fatima
    Nov 21 '18 at 17:20










  • @Leticia Unclear. So, solved? What's the final code? Did the above work? Or did I miss something?
    – TheMaster
    Nov 21 '18 at 17:58
















1












1








1






UrlFetchApp doesn't have a data key parameter. Use payload instead.



Reference:



UrlFetchApp



Code Snippet:



UrlFetchApp.fetch(url,
{
method: "POST",
headers: {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
},
contentType: 'application/json',
payload: JSON.stringify({
"action": "block"
}),
muteHttpExceptions: true
});





share|improve this answer














UrlFetchApp doesn't have a data key parameter. Use payload instead.



Reference:



UrlFetchApp



Code Snippet:



UrlFetchApp.fetch(url,
{
method: "POST",
headers: {
"Authorization": "Bearer " + ScriptApp.getOAuthToken(),
},
contentType: 'application/json',
payload: JSON.stringify({
"action": "block"
}),
muteHttpExceptions: true
});






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 21 '18 at 16:58

























answered Nov 21 '18 at 16:39









TheMaster

9,5303731




9,5303731












  • when I use payload it points the error 'parse error'
    – Leticia Fatima
    Nov 21 '18 at 16:41










  • @Leticia Edit your question to show the new code and "Quote" the error
    – TheMaster
    Nov 21 '18 at 16:42










  • I added this to my code, I made the request and it returned the code 204. I made the get again, and the requested change in POST was not made.
    – Leticia Fatima
    Nov 21 '18 at 17:20










  • @Leticia Unclear. So, solved? What's the final code? Did the above work? Or did I miss something?
    – TheMaster
    Nov 21 '18 at 17:58




















  • when I use payload it points the error 'parse error'
    – Leticia Fatima
    Nov 21 '18 at 16:41










  • @Leticia Edit your question to show the new code and "Quote" the error
    – TheMaster
    Nov 21 '18 at 16:42










  • I added this to my code, I made the request and it returned the code 204. I made the get again, and the requested change in POST was not made.
    – Leticia Fatima
    Nov 21 '18 at 17:20










  • @Leticia Unclear. So, solved? What's the final code? Did the above work? Or did I miss something?
    – TheMaster
    Nov 21 '18 at 17:58


















when I use payload it points the error 'parse error'
– Leticia Fatima
Nov 21 '18 at 16:41




when I use payload it points the error 'parse error'
– Leticia Fatima
Nov 21 '18 at 16:41












@Leticia Edit your question to show the new code and "Quote" the error
– TheMaster
Nov 21 '18 at 16:42




@Leticia Edit your question to show the new code and "Quote" the error
– TheMaster
Nov 21 '18 at 16:42












I added this to my code, I made the request and it returned the code 204. I made the get again, and the requested change in POST was not made.
– Leticia Fatima
Nov 21 '18 at 17:20




I added this to my code, I made the request and it returned the code 204. I made the get again, and the requested change in POST was not made.
– Leticia Fatima
Nov 21 '18 at 17:20












@Leticia Unclear. So, solved? What's the final code? Did the above work? Or did I miss something?
– TheMaster
Nov 21 '18 at 17:58






@Leticia Unclear. So, solved? What's the final code? Did the above work? Or did I miss something?
– TheMaster
Nov 21 '18 at 17:58




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416512%2fmobiledevices-action-missing%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'