Jak dostać ASP.NET Web API zwróci JSON zamiast XML za pomocą Chrome?
Używanie nowszego ASP.NET Web API , W Chrome widzę XML-jak Mogę zmienić go na request JSON , aby móc go wyświetlić w przeglądarce? Wierzę, że to tylko część nagłówków żądań, czy mam rację?
29 answers
Dodaję po prostu w App_Start / WebApiConfig.cs
klasie w moim projekcie MVC Web API.
config.Formatters.JsonFormatter.SupportedMediaTypes
.Add(new MediaTypeHeaderValue("text/html") );
To daje pewność, że otrzymasz json na większość zapytań, ale możesz uzyskać {[2] } Kiedy wyślesz text/xml
.
Jeśli potrzebujesz mieć odpowiedź Content-Type
jako application/json
Sprawdź odpowiedź Todda poniżej .
NameSpace
używa System.Net.Http.Headers
;
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-07-03 19:42:06
Jeśli to zrobisz w WebApiConfig
domyślnie otrzymasz JSON, ale nadal będzie on umożliwiał zwrócenie XML, jeśli przekażesz text/xml
jako nagłówek request Accept
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");
config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
}
}
Jeśli nie używasz typu projektu MVC i dlatego nie masz tej klasy na początku, zobacz tę odpowiedź aby uzyskać szczegóły, jak ją włączyć.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:34:53
Najbardziej podoba mi się podejście Felipe Leusina - Upewnij się, że przeglądarki otrzymują JSON bez narażania negocjacji treści od klientów, którzy rzeczywiście chcą XML. Jedynym brakującym fragmentem dla mnie było to, że nagłówki odpowiedzi nadal zawierały content-type: text / html. Dlaczego to był problem? Ponieważ używam rozszerzenia JSON Formatter Chrome , które sprawdza typ zawartości i nie dostaję ładnego formatowania, do którego jestem przyzwyczajony. Naprawiłem to za pomocą prostego niestandardowego formatera, który akceptuje tekst / html wnioski i zwroty aplikacji / odpowiedzi json:
public class BrowserJsonFormatter : JsonMediaTypeFormatter
{
public BrowserJsonFormatter() {
this.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
this.SerializerSettings.Formatting = Formatting.Indented;
}
public override void SetDefaultContentHeaders(Type type, HttpContentHeaders headers, MediaTypeHeaderValue mediaType) {
base.SetDefaultContentHeaders(type, headers, mediaType);
headers.ContentType = new MediaTypeHeaderValue("application/json");
}
}
Zarejestruj się tak:
config.Formatters.Add(new BrowserJsonFormatter());
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:10:47
Używanie RequestHeaderMapping działa jeszcze lepiej, ponieważ ustawia również Content-Type = application/json
w nagłówku odpowiedzi, co pozwala Firefoxowi (z dodatkiem JSONView) sformatować odpowiedź jako JSON.
GlobalConfiguration.Configuration.Formatters.JsonFormatter.MediaTypeMappings
.Add(new System.Net.Http.Formatting.RequestHeaderMapping("Accept",
"text/html",
StringComparison.InvariantCultureIgnoreCase,
true,
"application/json"));
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-06-19 12:50:28
MVC4 Quick Tip #3-Usuwanie Formatera XML z ASP.Net Web API
W Global.asax
Dodaj wiersz:
GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
Like so:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
BundleTable.Bundles.RegisterTemplateBundles();
GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-08-06 13:00:36
W WebApiConfig.cs , Dodaj do końca Register function:
// Remove the XML formatter
config.Formatters.Remove(config.Formatters.XmlFormatter);
Źródło .
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-12-08 20:18:56
W globalnym.asax używam poniższego kodu. Mój URI do JSON to http://www.digantakumar.com/api/values?json=true
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
GlobalConfiguration.Configuration.Formatters.JsonFormatter.MediaTypeMappings.Add(new QueryStringMapping("json", "true", "application/json"));
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-12-08 20:51:49
Spójrz na negocjacje treści w WebAPI. These (Part 1 & Część 2 ) cudownie szczegółowe i dokładne posty na blogu wyjaśniają, jak to działa.
W skrócie, masz rację i wystarczy ustawić Accept
LUB Content-Type
nagłówki żądań. Ponieważ Twoja akcja nie jest zakodowana, aby zwrócić określony format, możesz ustawić Accept: application/json
.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-11-09 19:20:13
Ponieważ pytanie jest specyficzne dla Chrome, możesz uzyskać rozszerzenie Postman, które pozwala ustawić typ treści żądania.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-09-27 10:40:29
Jedną z szybkich opcji jest użycie specjalizacji MediaTypeMapping. Oto przykład użycia QueryStringMapping w zdarzeniu Application_Start:
GlobalConfiguration.Configuration.Formatters.JsonFormatter.MediaTypeMappings.Add(new QueryStringMapping("a", "b", "application/json"));
Teraz, gdy url zawiera querystring ?a = b w tym przypadku odpowiedź Json zostanie wyświetlona w przeglądarce.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-03-27 05:08:37
Ten kod czyni json moim domyślnym i pozwala mi również używać formatu XML. Dodam tylko xml=true
.
GlobalConfiguration.Configuration.Formatters.XmlFormatter.MediaTypeMappings.Add(new QueryStringMapping("xml", "true", "application/xml"));
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
Dziękuję wszystkim!
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-07-11 15:17:26
Nie używaj przeglądarki do testowania API.
Zamiast tego spróbuj użyć klienta HTTP, który pozwala określić żądanie, takie jak CURL, a nawet Fiddler.
Problem z tym problemem jest w kliencie, a nie w API. Web API zachowuje się poprawnie, zgodnie z żądaniem przeglądarki.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-04-25 21:26:14
Większość powyższych odpowiedzi ma sens. Ponieważ widzisz dane formatowane w formacie XML, oznacza to, że formatowanie XML jest stosowane, więc możesz zobaczyć format JSON po prostu usuwając XMLFormatter z parametru HttpConfiguration takiego jak
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Formatters.Remove(config.Formatters.XmlFormatter);
config.EnableSystemDiagnosticsTracing();
}
Ponieważ JSON jest formatem domyślnym
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-04-13 06:26:19
Użyłem globalnego filtra akcji do usunięcia Accept: application/xml
, gdy nagłówek User-Agent
zawiera "Chrome":
internal class RemoveXmlForGoogleChromeFilter : IActionFilter
{
public bool AllowMultiple
{
get { return false; }
}
public async Task<HttpResponseMessage> ExecuteActionFilterAsync(
HttpActionContext actionContext,
CancellationToken cancellationToken,
Func<Task<HttpResponseMessage>> continuation)
{
var userAgent = actionContext.Request.Headers.UserAgent.ToString();
if (userAgent.Contains("Chrome"))
{
var acceptHeaders = actionContext.Request.Headers.Accept;
var header =
acceptHeaders.SingleOrDefault(
x => x.MediaType.Contains("application/xml"));
acceptHeaders.Remove(header);
}
return await continuation();
}
}
Wygląda na to, że działa.Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-06-23 14:47:02
Uznałem aplikację Chrome "Advanced Rest Client" za doskonałą do pracy z usługami REST. Możesz ustawić Content-Type na application/json
między innymi:
Advanced Rest client
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-09-30 07:42:04
Zwracanie poprawnego formatu jest wykonywane przez program formatujący typu media.
Jak inni wspominali, możesz to zrobić w klasie WebApiConfig
:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
...
// Configure Web API to return JSON
config.Formatters.JsonFormatter
.SupportedMediaTypes.Add(new System.Net.Http.Headers.MediaTypeHeaderValue("text/html"));
...
}
}
Aby uzyskać więcej, sprawdź:
Jeśli Twoje akcje zwracają XML (co jest domyślnie) i potrzebujesz tylko określonej metody, aby zwrócić JSON, możesz użyć ActionFilterAttribute
i zastosować ją do tego konkretnego akcja.
Atrybut filtra:
public class JsonOutputAttribute : ActionFilterAttribute
{
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
ObjectContent content = actionExecutedContext.Response.Content as ObjectContent;
var value = content.Value;
Type targetType = actionExecutedContext.Response.Content.GetType().GetGenericArguments()[0];
var httpResponseMsg = new HttpResponseMessage
{
StatusCode = HttpStatusCode.OK,
RequestMessage = actionExecutedContext.Request,
Content = new ObjectContent(targetType, value, new JsonMediaTypeFormatter(), (string)null)
};
actionExecutedContext.Response = httpResponseMsg;
base.OnActionExecuted(actionExecutedContext);
}
}
Zastosowanie do działania:
[JsonOutput]
public IEnumerable<Person> GetPersons()
{
return _repository.AllPersons(); // the returned output will be in JSON
}
Zauważ, że możesz pominąć słowo Attribute
na dekoracji akcji i użyć tylko [JsonOutput]
zamiast [JsonOutputAttribute]
.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-12-09 16:27:58
Nie jest dla mnie jasne, dlaczego jest cała ta złożoność w odpowiedzi. Oczywiście istnieje wiele sposobów, aby to zrobić, z QueryStrings, nagłówki i opcje... ale to, co uważam za najlepszą praktykę, jest proste. Żądasz zwykłego adresu URL (np.: http://yourstartup.com/api/cars
), a w zamian otrzymujesz JSON. Otrzymujesz JSON z odpowiednim nagłówkiem odpowiedzi:
Content-Type: application/json
Szukając odpowiedzi na to samo pytanie, znalazłem ten wątek i musiałem kontynuować, ponieważ ta zaakceptowana odpowiedź nie działa dokładnie. I znalazłem odpowiedź, która moim zdaniem jest po prostu zbyt prosta, aby nie być najlepszą: {]}
Ustawienie domyślnego formatera WebAPI
Tutaj też dodam napiwek.WebApiConfig.cs
namespace com.yourstartup
{
using ...;
using System.Net.Http.Formatting;
...
config.Formatters.Clear(); //because there are defaults of XML..
config.Formatters.Add(new JsonMediaTypeFormatter());
}
Mam pytanie, skąd się biorą domyślne (przynajmniej te, które widzę). Czy są to domyślne. NET, czy może stworzone gdzieś indziej (przez kogoś innego w moim projekcie). Anways, mam nadzieję, że to pomoże.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 10:31:37
Oto rozwiązanie podobne do jayson.centeno ' s i inne odpowiedzi, ale używając wbudowanego rozszerzenia z System.Net.Http.Formatting
.
public static void Register(HttpConfiguration config)
{
// add support for the 'format' query param
// cref: http://blogs.msdn.com/b/hongyes/archive/2012/09/02/support-format-in-asp-net-web-api.aspx
config.Formatters.JsonFormatter.AddQueryStringMapping("$format", "json", "application/json");
config.Formatters.XmlFormatter.AddQueryStringMapping("$format", "xml", "application/xml");
// ... additional configuration
}
Rozwiązanie było przede wszystkim nastawione na obsługę formatu $dla OData we wczesnych wydaniach WebApi, ale ma również zastosowanie do implementacji nie-OData i zwraca
Content-Type: application/json; charset=utf-8
nagłówek w odpowiedzi.
Pozwala na przyłożenie &$format=json
lub &$format=xml
do końca uri podczas testowania z przeglądarką. Nie koliduje z innymi oczekiwanymi zachowanie podczas korzystania z klienta spoza przeglądarki, w którym można ustawić własne nagłówki.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:18:27
Po prostu zmień App_Start/WebApiConfig.cs
w ten sposób:
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
//Below formatter is used for returning the Json result.
var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");
config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
//Default route
config.Routes.MapHttpRoute(
name: "ApiControllerOnly",
routeTemplate: "api/{controller}"
);
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-02-08 05:03:12
Zgodnie z najnowszą wersją ASP.net WebApi 2,
Pod WebApiConfig.cs
to zadziała
config.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
config.Formatters.Add(GlobalConfiguration.Configuration.Formatters.JsonFormatter);
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-10-27 10:26:57
Wystarczy dodać te dwie linijki kodu na WebApiConfig klasa
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
//add this two line
config.Formatters.Clear();
config.Formatters.Add(new JsonMediaTypeFormatter());
............................
}
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-11-10 11:11:24
config.Formatters.Remove(config.Formatters.XmlFormatter);
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-07-01 04:31:36
Z MSDN budowanie aplikacji Jednostronicowej z ASP.NET i AngularJS (około 41 min).
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// ... possible routing etc.
// Setup to return json and camelcase it!
var formatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
formatter.SerializerSettings.ContractResolver =
new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
}
Powinno być aktualne, próbowałem i zadziałało.Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-09-30 19:19:10
Minęło trochę czasu od tego pytania (i odpowiedzi) , ale inną opcją jest nadpisanie nagłówka Accept na serwerze podczas przetwarzania żądania za pomocą MessageHandler jak poniżej:
public class ForceableContentTypeDelegationHandler : DelegatingHandler
{
protected async override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request,
CancellationToken cancellationToken)
{
var someOtherCondition = false;
var accHeader = request.Headers.GetValues("Accept").FirstOrDefault();
if (someOtherCondition && accHeader.Contains("application/xml"))
{
request.Headers.Remove("Accept");
request.Headers.Add("Accept", "application/json");
}
return await base.SendAsync(request, cancellationToken);
}
}
Gdzie {[4] } może być wszystko, w tym typ przeglądarki itp. Dotyczy to przypadków warunkowych, w których tylko czasami chcemy zastąpić domyślną negocjację zawartości. W przeciwnym razie, jak na inne odpowiedzi, po prostu usunąć niepotrzebny formatter z konfiguracja.
Musisz go oczywiście zarejestrować. Możesz to zrobić globalnie: public static void Register(HttpConfiguration config) {
config.MessageHandlers.Add(new ForceableContentTypeDelegationHandler());
}
Lub na podstawie trasy po trasie:
config.Routes.MapHttpRoute(
name: "SpecialContentRoute",
routeTemplate: "api/someUrlThatNeedsSpecialTreatment/{id}",
defaults: new { controller = "SpecialTreatment" id = RouteParameter.Optional },
constraints: null,
handler: new ForceableContentTypeDelegationHandler()
);
A ponieważ jest to funkcja obsługi wiadomości, będzie ona uruchamiana zarówno na końcach żądania, jak i odpowiedzi potoku, podobnie jak HttpModule
. Można więc łatwo uznać nadpisanie za pomocą niestandardowego nagłówka:
public class ForceableContentTypeDelegationHandler : DelegatingHandler
{
protected async override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request,
CancellationToken cancellationToken)
{
var wasForced = false;
var someOtherCondition = false;
var accHeader = request.Headers.GetValues("Accept").FirstOrDefault();
if (someOtherCondition && accHeader.Contains("application/xml"))
{
request.Headers.Remove("Accept");
request.Headers.Add("Accept", "application/json");
wasForced = true;
}
var response = await base.SendAsync(request, cancellationToken);
if (wasForced){
response.Headers.Add("X-ForcedContent", "We overrode your content prefs, sorry");
}
return response;
}
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-12-06 07:44:25
Oto najprostszy sposób, który zastosowałem w moich aplikacjach. Dodaj podane poniżej 3 linijki kodu w App_Start\\WebApiConfig.cs
w Register
funkcji
var formatters = GlobalConfiguration.Configuration.Formatters;
formatters.Remove(formatters.XmlFormatter);
config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));
Asp.net web API automatycznie serializuje zwracany obiekt do JSON i gdy application/json
zostanie dodany w nagłówku, przeglądarka lub odbiorca zrozumie, że zwracasz wynik JSON.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-05-28 10:49:51
WebApiConfig jest miejscem, w którym możesz skonfigurować, czy chcesz wypisywać w json czy xml. domyślnie jest to xml. w funkcji register możemy użyć Formaterów HttpConfiguration do sformatowania wyjścia . System. Net. Http. Headers => MediaTypeHeaderValue ("text / html") jest wymagane, aby uzyskać wyjście w formacie json.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-09-25 00:13:10
Możesz użyć jak poniżej:
GlobalConfiguration.Configuration.Formatters.Clear();
GlobalConfiguration.Configuration.Formatters.Add(new JsonMediaTypeFormatter());
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-04-11 10:21:38
Korzystanie z Felipe Leusin ' s odpowiedź od lat, po niedawnej aktualizacji podstawowych bibliotek i Json.Net, wpadłem na System.MissingMethodException
: SupportedMediaTypes.
Rozwiązaniem w moim przypadku, mam nadzieję, pomocnym dla innych, którzy doświadczają tego samego nieoczekiwanego wyjątku, jest zainstalowanie System.Net.Http
. NuGet najwyraźniej usuwa go w pewnych okolicznościach. Po ręcznej instalacji problem został rozwiązany.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-04-13 19:42:40
Jestem zdumiony, widząc tak wiele odpowiedzi wymagających kodowania, aby zmienić pojedynczy przypadek użycia (GET) w JEDEN API zamiast używać odpowiedniego narzędzia, które musi być zainstalowane raz i może być używane dla dowolnego API (własnego lub 3rd party) i wszystkich przypadków użycia.
Więc dobra odpowiedź brzmi:
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-11-30 23:01:52