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; }
}