Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ArtemMsk
Regular Visitor

Requests to the REST API POST method

Hi everyone! 

The code below returns me an error: (400): Bad Request.

I know the error in the line below (to be more specific the problem is: "", ""filter"":{""since"": ""2019-12-10"", ""to"": ""2019-12-11""} 😞 

      body = "{""dir"": ""asc"", ""filter"":{""since"": ""2019-12-10"", ""to"": ""2019-12-11""}, ""status"":""delivered"", ""limit"": ""10"", ""offset"": ""0"" }",

 

but I don’t know exactly what syntax should be. May you help me with it?

 

The full code is:

 

let

    url = "http://api-seller.ozon.ru/v2/posting/fbo/list",

    body = "{""dir"": ""asc"", ""filter"":{""since"": ""2019-12-10"", ""to"": ""2019-12-11""}, ""status"":""delivered"", ""limit"": ""10"", ""offset"": ""0"" }",

    Options=[Headers = [  #"client-id"="466", #"api-key"="-9753260e-2324-fde7-97f1-7848ed7ed097", #"Content-Type"="application/json"],Content = Text.ToBinary(body) ],

    Source = Json.Document(Web.Contents(url,Options)),

in Source

 

HTTP Request example:

POST /v2/posting/fbo/list HTTP/1.1

Host: api-seller.ozon.ru

Client-Id: 466

Api-Key: 9753260e-2324-fde7-97f1-7848ed7ed097

Content-Type: application/json

 

{

    "dir": "asc",

    "filter":

    {

        "since": "2018-10-24T16:24:09.474Z",

        "to": "2019-10-24T16:24:09.474Z"

    },

    "limit": 10,

    "offset": 0

}

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @ArtemMsk 

Please follow the guide in the similar thread.

Please ensure your network has access to the url.

I can't have access to the url on my side.

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-juanli-msft 

Thanks for your reply. 

I've checked the mentioned guide before. it was useful. 

As for network access, there is no problem. For example, the following code works just fine:

 

let
    url = "http://api-seller.ozon.ru/v1/product/info/stocks",
    body = "{""page"": ""1"", ""page_size"": ""100""}",
    Options=[Headers = [ #"client-id"="ххх", #"api-key"="хххх-хххх-хххх-хххх-хххх", #"Content-Type"="application/json"],Content          = Text.ToBinary(body) ],
   Source = Json.Document(Web.Contents(url,Options))
in Source

 

The same code but different line in the "body" part does not work: body = "{""dir"": ""asc"", ""filter"":{""since"": ""2019-12-10"", ""to"": ""2019-12-11""}, ""status"":""delivered"", ""limit"": ""10"", ""offset"": ""0"" }",

is it syntax of the code correct?

 

The problem solved.  There is a wrong sequence in the parameters and format of the date.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors