Square Connect API List Locations and Inventory Adjust return 404 not found

I am able to get all the categories and all of the items with no problem. When I try to get a list of locations or adjust inventory I get an error message.

My code to get the locations: WebRequest request = WebRequest.Create("https://connect.squareup.com/v1/me/locations"); request.ContentType = "application/json"; request.Method = "GET"; request.Headers["Authorization"] = "Bearer xxxxxxxxxxxxxxxxxxxxxx";

        HttpWebResponse response = null;
        string responseMessage = null;
        response = (HttpWebResponse)request.GetResponse();

        if (response.StatusCode == HttpStatusCode.OK)
        {
            using (Stream stream = response.GetResponseStream())
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    responseMessage = reader.ReadToEnd();
                }
            }
        }

My code to adjust the inventory is: Uri uri = new System.Uri(string.Format("https://connect.squareup.com/v1/me/inventory/{0}", variationId)); WebRequest request = WebRequest.Create(uri); request.ContentType = "application/json"; request.Method = "PUT"; request.Headers["Authorization"] = "Bearer xxxxxxxxxxxxxxxxxxxxxx";

        string postData = "{"quantity_delta":" + adjustAmount.ToString() + ","adjustment_type":"MANUAL_ADJUST"}";
        byte[] byteArray = Encoding.UTF8.GetBytes (postData);
        request.ContentLength = byteArray.Length;
        Stream dataStream = request.GetRequestStream ();
        dataStream.Write (byteArray, 0, byteArray.Length);
        dataStream.Close ();

        HttpWebResponse response = null;
        string responseMessage = null;
        response = (HttpWebResponse)request.GetResponse();

        if (response.StatusCode == HttpStatusCode.OK)
        {
            using (Stream stream = response.GetResponseStream())
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    responseMessage = reader.ReadToEnd();
                }
            }
        }

For both of the at the line response = (HttpWebResponse)request.GetResponse(); I get The remote server returned an error: (404) Not Found

Any help is very much appreciated as I do not understand why part of my code is working but these two pieces are not.


An app needs to be created after 02/16/2016 to use the v1 locations endpoint, as indicated in the Business Management Overview section: "The endpoints described in this section cannot be used by applications that were created before 16 February 2016. See Connect API changes (2016-02-16) for more information." Could you verify if the app was created after 02/16/2016? If not, could you please create a new app and give it a try?

For the 404 on inventory adjustment, could you please provide an item variation ID for further investigation?

链接地址: http://www.djcxy.com/p/45900.html

上一篇: grails元编程

下一篇: Square Connect API列表位置和库存调整返回404找不到