GAS:使用UrlFetchApp时出错

时间:2016-04-07 00:57:32

标签: google-apps-script

我正在使用senotp serverside api来验证号码。当使用具有相同内容的soap ui运行时,没有错误。但是当我使用#! /bin/sh # # git-reword: use git rebase -i to reword one particular commit SUBDIRECTORY_OK=Yes USAGE="<commit>" . $(git --exec-path)/git-sh-setup case $# in 1) ;; *) usage;; esac rev=$(git rev-parse "$1") || exit 1 # We now know which commit to reword; find it relative to HEAD, # and find the parent argument to pass to "git rebase -i". # If we wanted to allow multiple rewords we would need to sort # them topologically so as to find the correct parent argument. # "git rev-list --no-walk --topo-order <rev> <rev> ..." can do this # now, but watch out, older rev-lists do not apply the sort if there # are specific revisions listed on the command line. if ! git merge-base --is-ancestor $rev HEAD; then fatal "$1 is not an ancestor of HEAD, cannot reword by rebasing" fi # Is it the root commit? Are there merges between it and HEAD? if parent=$(git rev-parse -q --verify ${rev}^); then # it has a (first) parent, so don't need --root nmerge=$(git rev-list --count --merges $parent..HEAD) else # it has no first parent, so use --root instead parent="--root" nmerge=$(git rev-list --count --merges HEAD) fi # Refuse to run if there are merges. This is partly a matter # of taste since we could attempt to combine -i and -p (since # we are not deleting any pick lines) but it's definitely safer # to refuse to re-do merges: we don't know if there are evil # merges, for instance, nor want to force manual re-merges. if [ $nmerge -gt 0 ]; then [ $nmerge -gt 1 ] && msg="are $nmerge merges" || msg="is a merge" fatal "Cannot reword: there $msg in the way." fi require_clean_work_tree "reword" "Please commit or stash them." # If we allowed merges, the pick line we want might not be # the very first pick command; but we don't, so it is, so # that makes our "editor" pretty easy. # If we want to allow multiple reword hashes, change this # to write a script that reads each line and matches SHA-1s # (we need to expand them a la git-rebase--interactive and # then match them against the IDs we'd like to reword). TF=$(mktemp) trap "rm -f $TF" 0 1 2 3 15 cat << END > $TF #! /bin/sh # change first line from "pick ..." to "reword ..." # copy the remaining lines unchanged sed -e '1s/^pick/reword/' END chmod +x $TF GIT_SEQUENCE_EDITOR=$TF git rebase -i $parent 时,它会出错:

UrlFetchApp

而正确的回答应该是:

{"status":"error","response":{"code":"INVALID_REQUEST_BODY"}}

我使用的代码是foll0ws:

{
   "status": "success",
   "response":    {
      "code": "OTP_SENT_SUCCESSFULLY",
      "oneTimePassword": "34859"
   }
}

我不确定这里有什么问题。请帮我调试一下,或者让我知道代码有什么问题。

1 个答案:

答案 0 :(得分:1)

似乎在GAS fetchService中使用payload会自动生成contentType : application/x-www-form-urlencodedcontentType : multipart/form-data

请参阅文档:https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetch(String,Object)

不幸的是,我还没有找到解决方法。