Rest API не работает на C#, но работает в PostmanC#

Место общения программистов C#
Ответить
Anonymous
 Rest API не работает на C#, но работает в Postman

Сообщение Anonymous »


Currently, I am consuming a service in postman to consult a specific endpoint, in postman the only thing I do is paste the URL in the request with parameters included, and it returns the content correctly, but when I do the same process from C#, it responds (OK200), but in data I get nothing.

This is the URL endpoint: https://citaconsular.es/onlinebookings/ ... 7334634682

This is my Postman case


Изображение


And this is my c# petition, i'm using restSharp por this petition, I'm trying with httpClient as well

private static void FindAppointmentss() { try { var client = new RestClient("https://citaconsular.es"); var request = new RestRequest("/onlinebookings/getservices/", Method.Get); request.AddQueryParameter("callback", "jQuery2110803503481037606_1707334189954"); request.AddQueryParameter("type", "default"); request.AddQueryParameter("publickey", "2535680773512eb064e273253a3ba5037"); request.AddQueryParameter("lang", "es"); request.AddQueryParameter("version", "1246"); request.AddQueryParameter("src", "https%3A%2F%2Fwww.citaconsular.es%2Fes%2Fhosteds%2Fwidgetdefault%2F2535680773512eb064e273253a3ba5037%23services"); request.AddQueryParameter("srvsrc", "https%3A%2F%2Fcitaconsular.es"); request.AddQueryParameter("_", "1707334189957"); request.AddHeader("Accept", "application/javascript"); var response = client.Execute(request); if (response.IsSuccessful) { string content = response.Content; } else { Console.WriteLine("No data content: " + response.StatusCode); } } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } } I always get No data content

I tried to create a request from postman which was successful, as seen in the case description, I also tried to do it from c#, Nodejs and ReactJS. From c# and Nodejs, the response was successful, but it did not return data, as, for example, the Postman case does.

The expected answer is the next text callback, its content is application/javascript
callback=jQuery21106986789352158271_1707334634680({ "WidgetConfiguration": { "any_agenda": "2", "registration_type": "2", "waiting_list": "0", "show_comments": "0", "mandatory_comments": "0", "min_service_to_enable_dropdown": "0", "template": "1", "captcha": "0", "payment_enable": false, "payments_gateways": { "stripe": false, "paypal": false, "redsys": false, "niubiz": false } }, "WidgetLabel": [] });

Источник: https://stackoverflow.com/questions/779 ... in-postman
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»