0

I am trying to make request to delete comment via Instagram API. This is my code:

$.ajax({
    type: "POST",
    url: "https://api.instagram.com/v1/media/" + mediaId + "/comments/" + commentId + "?access_token=" + accessToken,
    data: { _method: "DELETE" },
    success: function(result){
        ...
    }
});

But I get this two errors:

  1. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://timetoplay.alexjcomp.lclients.ru' is therefore not allowed access. The response had HTTP status code 400.

  2. Status Code:400 BAD REQUEST

First is from console and second from network tab in chrome. As I understand my problem is that I can not make CORS Post request. With CORS GET request everything was just fine because I used dataType: "jsonp". How can I fix it in this case?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

1

Check this link for how to delete an Instagram comment:

http://instagram.com/developer/endpoints/comments/#delete_media_comments

And I didn't test this code but I would assume all you need is this:

$.ajax({
    type: "DELETE",
    url: "https://api.instagram.com/v1/media/" + mediaId + "/comments/" + commentId + "?access_token=" + accessToken,
    success: function(result){
        ...
    }
});
Jim Moody
  • 758
  • 2
  • 6
  • 18
0

as mentioned by Jim instagram docs are here I noted that you are also passing commentId which is not needed , just mention the media id like this

https://api.instagram.com/v1/media/{media-id}/comments?access_token=ACCESS-TOKEN

your ajax should look something like this:

$.ajax({
        type: "DELETE",
        url: "https://api.instagram.com/v1/media/" + mediaId + "/comments/?access_token=" + accessToken,
        success: function(result){
            ...
        }
    });

I haven't tested it but you can give it a try.Hope it helps.

Aameer
  • 1,366
  • 1
  • 11
  • 30