This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Description
UrlFetchApp.fetch() works incorrectly when the payload is an object and one or more of the parameter values contains an ampersand (&). This creates issues with sending OAuthed statuses with ampersands to Twitter, for example. You will get "Could not authenticate you" errors because the post body sent by UrlFetchApp does not correspond to the one used to created the signature.
I recommend manually stringifying the payload to a correct POST body before sending the data if the content is going to be urlencoded (this is what I was doing under the old OAuth service, and worked well). However, if there is a blob in the payload, it will be sent multipart/form-data instead, so check for that:
//Service.gs, line 398
// Service_.prototype.fetchInternal_()
if(params.payload && !Object.keys(params.payload).reduce(function(truth, key) {
return truth || typeof params.payload[key] === "object";
}, false)) {
params.payload = signer.getParameterString(request, {});
}
return UrlFetchApp.fetch(url, params);