bulk/batch request

I'm trying to use the bulk/batch endpoint to batch a ton of requests at 50 requests a piece. I'm trying to just get this working in Postman first but I'm not able to figure out how to send all the data. I have the key set as a header and the JSON data as application/json data.

See screenshots https://i.imgur.com/p9QrQ2w.png and https://i.imgur.com/vUUMxiv.png

I've tried different ways to send this and always get 403 Forbidden (Access Denied).

What's the right way to send to this request?

Comments

  • 7 Comments sorted by Votes Date Added
  • I believe the key would need to be in the body as opposed to a header
  • I've tried that variation as well and no luck

    {
    "key": {{key}},
    "request": [...]
    }
  • Would you be able to post the screenshots as before? I had to test it out myself in Postman earlier and was able to get it to work via POST with the key in the body. I don’t believe it needed any headers.
  • Sorry for the delay. Here's what I've done https://i.imgur.com/W0BfIOL.png

    There is one header but that's just defining the Content-type: application/json

    I still get a 403 Access Denied.

    Here's the full json data in case that is helpful https://gist.github.com/RedWolves/2d647b0c9c4d6ad931939cc40879ae80

    Appreciate your help.
  • You may want to set the body to form-data, or the x-www option, I tried it on one of those as opposed to RAW. The Key should not be part of the JSON, that should be a seperate post parameter. This should essentially just be a normal POST request with one parameter being the key and the other being the requests
  • That worked. That seems a little bit wonky. I expected that JSON data to be sent as data in the post. Can you update the docs to make that more clear?
  • This how I solved it in C#, the Bulk entry in the manual should really be updated.

    [ContentType]
    application/x-www-form-urlencoded

    [Data Structure]
    key = secretkey
    requests = {"requests": [{"endpoint":"inventory/update","request_method":"POST","params":[{"lot_id":"IDHERE","absolute_quantity":2}]}]}

    [Response]
    [{"req_num":1,"code":200,"body":{"status":"Success"}}]

    [Example]
    var jsonRequest = JsonConvert.SerializeObject(data, new JsonSerializerSettings()
    {
    NullValueHandling = NullValueHandling.Ignore,
    StringEscapeHandling = StringEscapeHandling.EscapeNonAscii,
    Converters = new List<JsonConverter>() { new BrickOwlApiDateTimeConverter() }
    });
    jsonRequest = jsonRequest.Replace("\"parameters\":", "\"params\":");
    var query = new NameValueCollection();
    query.Add("key", "MYSECRETKEY");
    query.Add("requests", jsonRequest);
    byte[] bytes = client.UploadValues(url, WebRequestMethods.Http.Post, query);
    jsonResponse = Encoding.UTF8.GetString(bytes);
Sign In or Register to comment.