У меня есть простой ресурс, который предоставляет список переводов. Конечная точка get берет язык и возвращает словарь переводов. Любые обновления будут только на одном переводе, поэтому я решил, что было бы целесообразно сделать это как патч..NET web api HttpPatch возвращается 403 запрещено
В моем контроллере api я могу сделать работу с файлами в порядке, но любой вызов, который я делаю для конечной точки моего патча, дает мне 403 запрещенную ошибку, и я не понимаю, почему.
[HttpGet]
// GET api/<controller>
public Dictionary<string,string> Get(String id)
{
return TranslationSvc.GetTranslatedStrings(id);
}
[HttpPatch]
public TranslationEntry Patch(TranslationEntry data)
{//403 prevents this end point from ever executing
if (TranslationSvc.UpdateTranslation(data.Lang, "", data.Translation.Key, data.Translation.Value))
{
return data;
}
else
{
//return a 500 error;
throw new HttpResponseException(HttpStatusCode.InternalServerError);
}
}
[HttpPut]
public TranslationEntry Put(TranslationEntry data)
{//works, but technically a put should be the full resource which is the full collection
if (TranslationSvc.UpdateTranslation(data.Lang, "", data.Translation.Key, data.Translation.Value))
{
return data;
}
else
{
//return a 500 error;
throw new HttpResponseException(HttpStatusCode.InternalServerError);
}
}