• 18-12-2023, 10:59:01
    #1
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Merhabalar c# üzerinden


    static async Task Main(string[] args)
    {
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Get, "https://listing-external.hepsiburada.com/Listings/merchantid/a19ede53-24d9-44c4-9280-e606d33a528d?offset=0&limit=10");
    request.Headers.Add("Authorization", "Basic b23zzR0b21hcxmas1hcmXFfZGV2Oam1yelpKZm14FDSEhQQiEs 2=");
    var response = await client.SendAsync(request);
    response.EnsureSuccessStatusCode();
    Console.WriteLine(await response.Content.ReadAsStringAsync());

    }
    şeklinde methodumda 401 hatası almaktayım aynı kodu python üzerinde

    import requests

    headers = {
    'Authorization': 'Basic b23zzR0b21hcxmas1hcmXFfZGV2Oam1yelpKZm14FDSEhQQiEs 2 =',
    }

    url = 'https://listing-external.hepsiburada.com/Listings/merchantid/a19ede53-24d9-44c4-9280-e606d33a528d?offset=0&limit=10'

    response = requests.get(url, headers=headers)

    if response.status_code == 200:
    print(response.json()) # Yanıtın JSON içeriğini yazdır
    else:
    print('İstek başarısız:', response.status_code)
    çalıştırdığım zaman lsite gelmekte. c# tarafında neden 401 almaktayım? auth. hatası vermekte. pythonda sorunsuz çalışmakta.
  • 18-12-2023, 11:06:57
    #2
    Hepsiburada MarketPlace:


    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    String encoded = System.Convert.ToBase64String(System.Text.Encoding .GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://oms-external.hepsiburada.com/orders/merchantid/" + suplierid + "?offset=0&limit=100");
    request.Method = "GET";
    request.Headers.Add("Authorization", "Basic " + encoded);
  • 18-12-2023, 11:48:21
    #3
    tuqcan adlı üyeden alıntı: mesajı görüntüle
    Hepsiburada MarketPlace:


    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    String encoded = System.Convert.ToBase64String(System.Text.Encoding .GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://oms-external.hepsiburada.com/orders/merchantid/" + suplierid + "?offset=0&limit=100");
    request.Method = "GET";
    request.Headers.Add("Authorization", "Basic " + encoded);
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    string encoded = System.Convert.ToBase64String(System.Text.Encoding .GetEncoding("ISO-8859-1").GetBytes("sadfasf" + ":" + "fdasfsdaf"));
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://listing-external.hepsiburada.com/Listings/merchantid/a19ede53-24d9-441c4-9280-e606d323a528d?offset=0&limit=10");
    request.Method = "GET";
    request.Headers.Add("Authorization", "Basic " + encoded);

    HttpWebResponse response = (HttpWebResponse)request.GetResponse();

    using (Stream stream = response.GetResponseStream())
    using (StreamReader reader = new StreamReader(stream))
    {
    string responseText = reader.ReadToEnd();
    Console.WriteLine(responseText); // Cevabı ekrana yazdır
    }
    hocam bu sekilde de : Uzak sunucu hata döndürdü: (401) Onaylanmadı. hatası alıyorum. python tarafında çalışmaya devam ediyor.
  • 18-12-2023, 13:35:00
    #4
    Python ile C# aynı ip'den mi çalışıyor ? Aynı bilgisayar dan mı istek atıyorsunuz ?
  • 21-12-2023, 17:02:51
    #5
    redgen01 adlı üyeden alıntı: mesajı görüntüle
    Python ile C# aynı ip'den mi çalışıyor ? Aynı bilgisayar dan mı istek atıyorsunuz ?
    Evet hocam aynı pcden atıyorum.