最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Making a simple POST request with the pastebin API - Stack Overflow

programmeradmin4浏览0评论

I was wondering how I would be able to make a post request to pastebin. They have an easy to understand API documentation, but whenever I run a simple POST request I always get Bad API request, invalid api_option.

I'm using the bear minimum required to make the request, I'm not sure what I could be doing wrong.

var request = new XMLHttpRequest; request.open("POST", ".php?api_dev_key=mykey&api_option=paste&api_paste_code=hi", false); request.send(); request.response;

I was wondering how I would be able to make a post request to pastebin.. They have an easy to understand API documentation, but whenever I run a simple POST request I always get Bad API request, invalid api_option.

I'm using the bear minimum required to make the request, I'm not sure what I could be doing wrong.

var request = new XMLHttpRequest; request.open("POST", "https://pastebin./api/api_post.php?api_dev_key=mykey&api_option=paste&api_paste_code=hi", false); request.send(); request.response;

Share Improve this question asked May 19, 2018 at 23:01 AndrewAndrew 5281 gold badge6 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

Finally I made it work like this:

var request = new XMLHttpRequest();

request.open("POST", "https://pastebin./api/api_post.php", true);

request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

request.send("api_dev_key=YOUR_KEY_HERE&api_option=paste&api_paste_private=0&api_paste_name=myname.js&api_paste_expire_date=10M&api_paste_format=javascript&api_paste_code=random");

I hope it helps

发布评论

评论列表(0)

  1. 暂无评论