Aby wyszukać produkty na Allegro wykonałem następujący kod:
Restrequest1.Client:= RestClient1;
RestClient1.BaseURL:= 'https://api.allegro.pl.allegrosandbox.pl';
RestRequest1.Method := TRESTRequestMethod.rmGET;
RestRequest1.Resource := 'sale/products';
RestRequest1.AddParameter('Authorization', 'Bearer ' + access_token,
TRESTRequestParameterKind.pkHTTPHEADER, [TRESTRequestParameterOption.poDoNotEncode]);
RestRequest1.AddParameter('Accept', 'application/vnd.allegro.public.v1+json',
TRESTRequestParameterKind.pkHTTPHEADER, [TRESTRequestParameterOption.poDoNotEncode]);
RestClient1.ContentType:='application/vnd.allegro.public.v1+json';
RESTRequest1.AddParameter('phrase', search_name.Text, TRESTRequestParameterKind.pkGETorPOST);
if (category_name_combobox.ItemIndex <> (-1)) then
begin
RESTRequest1.AddParameter('category.id', string(category_name_combobox.Items.Objects[category_name_combobox.ItemIndex]), TRESTRequestParameterKind.pkGETorPOST);
end;
RestRequest1.Execute;
result.Text := RESTResponse1.Content;
i w odpowiedzi otrzymuję ze statusem 401:
{"errors":[{"code":"AccessDeniedException","message":"Access denied.","details":null,"path":null,"userMessage":"Access denied."}]}
Jak zrobić żeby ten błąd nie wyświetlał się i żeby można było wyszukiwać produkty na Allegro ?