Instagram The remote server returned an error: (42

2019-09-06 14:36发布

问题:

I'm working on some new programs using my own instagram api. Everything is working fine with me except following user script i wanna follow my list of users id so i use this code

        foreach (var item in listBox1.Items)
        {
            WebRequest request = WebRequest.Create("https://api.instagram.com/v1/users/"+item+"/relationship?access_token=" + Common.token2);
            request.Proxy = null;
            request.Method = "POST";
            string postData = "action=follow";
            byte[] byteArray = Encoding.UTF8.GetBytes(postData);
            // Set the ContentType property of the WebRequest.
            request.ContentType = "application/x-www-form-urlencoded";
            // Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length;
            // Get the request stream.
            Stream dataStream = request.GetRequestStream();
            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();
            WebResponse response = request.GetResponse();
            // Display the status.
            MessageBox.Show(((HttpWebResponse)response).StatusDescription);
            dataStream.Close();
            response.Close();
            new System.Threading.Thread(GetInfo).Start();
            Thread.Sleep(TimeSpan.FromSeconds(2));
        }
        listBox1.Items.Clear();

it follow first 5 successfully then it return with

The remote server returned an error: (429) UNKNOWN STATUS CODE.

回答1:

The follow API call only allows 20 API calls/hour. After this limit, you will get 429 error

If you implement signed calls then you can do 60 calls/hour.

Here are details of the limits. https://instagram.com/developer/limits/