• Najnowsze pytania
  • Bez odpowiedzi
  • Zadaj pytanie
  • Kategorie
  • Tagi
  • Zdobyte punkty
  • Ekipa ninja
  • IRC
  • FAQ
  • Regulamin
  • Książki warte uwagi

Allegro - Rest - błąd Unsupported Media Type

VMware Cloud PRO - przenieś swoją infrastrukturę IT do chmury
0 głosów
1,652 wizyt
pytanie zadane 3 grudnia 2017 w C# przez jacek_lodz Nowicjusz (120 p.)

Cześć

Mam problem z pobraniem informacji z REST Allegro.

Poniżej kod oraz informacja jaka jest zwracana z Allegro:

{"errors":[{"code":"NotSupportedException","message":"Unsupported Media Type","details":null,"path":null,"userMessage":"An error occurred"}]}

Czy ktoś ma może pomysł co jest nie tak?

Dodam iż już wstawiałem/podmieniałem request.AddHeader("Content-Type", "application/json"); i żadnych zmian.

Pomocy.

 


   protected void Page_Load(object sender, EventArgs e)
        {
            var client = new RestClient("https://allegroapi.io");

            var request = new RestRequest("pricing/fee-preview ", Method.POST);

            request.AddHeader("Accept", "application/vnd.allegro.public.v1+json");
            request.AddHeader("Content-Type", "application/vnd.allegro.public.v1+json");
            //request.AddHeader("Content-Type", "application/json");
            //request.AddHeader("Authorization", String.Format("Bearer {0}", GetToken()));
            request.AddHeader("Accept-Language", "pl-PL");
            request.AddHeader("Api-Key", "eyJjbGllbnRJZCI......................3qYg=");


            RootObject o = new RootObject();
            o.offer = new Offer();
            o.offer.shop = true;
            o.offer.category = new Category();
            o.offer.category.id = "5318";
            o.offer.duration = "PT72H";
            o.offer.quantity = 1;
            o.offer.soldQuantity = 1;

            request.AddJsonBody(o);

            IRestResponse response = client.Execute(request);
            var content = response.Content; // raw content as string


        }
        public class Category
        {
            public string id { get; set; }
        }

        public class Offer
        {
            public Category category { get; set; }
            public string duration { get; set; }
            public bool hasAnyQuantity { get; set; }
            public int numberOfBigPhotos { get; set; }
            public int numberOfPhotos { get; set; }
            public int quantity { get; set; }
            public bool shop { get; set; }
            public int soldQuantity { get; set; }
            public string type { get; set; }
            public int unitPrice { get; set; }
            public bool bold { get; set; }
            public bool highlight { get; set; }
            public bool departmentPage { get; set; }
            public bool emphasized { get; set; }
            public bool emphasizedHighlightBoldPackage { get; set; }
        }

        public class RootObject
        {
            public bool includeQuotingBundles { get; set; }
            public Offer offer { get; set; }
        }

 

Zaloguj lub zarejestruj się, aby odpowiedzieć na to pytanie.

Podobne pytania

0 głosów
1 odpowiedź 1,417 wizyt
pytanie zadane 4 października 2018 w Sieci komputerowe, internet przez RafalS VIP (122,820 p.)
0 głosów
1 odpowiedź 3,731 wizyt
pytanie zadane 3 kwietnia 2017 w PHP przez Filius Gaduła (4,120 p.)
0 głosów
0 odpowiedzi 581 wizyt
pytanie zadane 21 września 2022 w PHP przez Piotr Popławski Użytkownik (610 p.)

93,443 zapytań

142,436 odpowiedzi

322,693 komentarzy

62,805 pasjonatów

Motyw:

Akcja Pajacyk

Pajacyk od wielu lat dożywia dzieci. Pomóż klikając w zielony brzuszek na stronie. Dziękujemy! ♡

Oto polecana książka warta uwagi.
Pełną listę książek znajdziesz tutaj

...