0

I am Able to Perform the GET Method for Tumblr Blog, But Whenever I try to Perform the POST Method for Tumblr then At that time I get an Error as::

({"meta":{"status":401,"msg":"Not Authorized"},"response":[]});

I am using the Following code for Ajax Post::

$.ajax({
    type: 'POST',
    url: 'https://api.tumblr.com/v2/blog/firstblgpsa.tumblr.com/post',
    dataType: "jsonp",
    data: {
        api_key: "*key here*",
        type: 'text',
        title: 'First_Post',
        body:'This is My First Post to Tumblr.'
    },
    success:function(){
        alert("Blog Posted Successfully!!");
    }
}) 
Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
Rahul RJ
  • 237
  • 3
  • 7
  • 15
  • 2
    `jsonp` doesn't support method POST. To be more precise, you can't use method other than GET in cross-domain ajax. http://stackoverflow.com/questions/4508198/how-to-use-type-post-in-jsonp-ajax-call – Haocheng Jun 17 '13 at 12:54
  • But what should I do If I want to Post Some text into My Tumblr Blog. – Rahul RJ Jun 17 '13 at 13:05
  • 1
    I don't think you want others to start using your key and upload stuff on your behalf, removed your key. – Shadow The GPT Wizard Jun 17 '13 at 13:23

1 Answers1

2

On the client side (in the browser) you are allowed from default to use only GET requests. This is the same origin policy. There are some tricks to go around this but I would not recommend doing that.

It's not even possible with JSONP see more details in q: How to use type: “POST” in jsonp ajax call question

What you should do:
The correct way of doing things like this is to send the request to your domains server (backend) and do the request against tumblr from your backend server directly with php or ruby or w/e you got there.

Community
  • 1
  • 1
p1100i
  • 3,710
  • 2
  • 29
  • 45
  • But If I am not Using that DataType in My AJAX POST method then also I am not able to Create a New Blog on Tumblr – Rahul RJ Jun 19 '13 at 13:05