bulk/batch: Access Denied

Hello,
I can use my own programm since a long time to post, update, etc. single items (e.g. create inventory).
Now I try to upload a bulk, but it fails all the time.

Here are some code snippets - maybe somebody has an idea to find the right path:

//Post data
string appUrl = "bulk/batch?key=" + boApiKey;
var client = new HttpClient()
{
BaseAddress = new Uri(baseURLBO + appUrl)
};
var httpContent = new StringContent(test2, Encoding.UTF8, "application/json");
var apiResponse = client.PostAsync(baseURLBO + appUrl, httpContent);
var resultRead = apiResponse.Result.Content.ReadAsStringAsync().Result;

//Variables are
baseURLBO + appUrl --> https://api.brickowl.com/v1/bulk/batch?key=THISISMYKEY
test2 --> {"requests":[{"endpoint":"inventory/create","request_method":"POST","params":[{"boid":"960521","color_id":"92","quantity":5,"price":98.17,"condition":"new"}]}]}

//The response is
{"error":"Access Denied"}


Have a great last day of the week and stay healthy,
Oliver.

Comments

  • 1 Comment sorted by Votes Date Added
  • Good Morning,
    now I have fixed it myself - I guess I shouldn't sit until late night in front of the computer. :smiley:

    This is the code how it works:
    string appUrl = "bulk/batch";
    HttpClient client = new HttpClient()
    {
    BaseAddress = new Uri(baseURLBO + appUrl)
    };
    List<KeyValuePair<string, string>> contentData = new List<KeyValuePair<string, string>>()
    {
    new KeyValuePair<string, string>("key", boApiKey),
    new KeyValuePair<string, string>("requests", contentJson)
    };
    HttpContent q = new FormUrlEncodedContent(contentData);
    q.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded");

    //Put Data
    var apiResponse = client.PostAsync(baseURLBO + appUrl, q);
    string response = apiResponse.Result.Content.ReadAsStringAsync().Result;

    contentJson --> {"requests":[{"endpoint":"inventory/create","request_method":"POST","params":[{"boid":"960521","color_id":"92","quantity":"5","price":"98.17","condition":"new"}]}]}


    Have a good time,
    Oliver.
Sign In or Register to comment.