187 questions
0
votes
2
answers
882
views
For use of the OpenAI API in Android Studio, does something need to be done with the Content Negotiation from Ktor?
I am trying to develop an app as well as learn Kotlin. I decided to create an app that allows a User to create a story using AI, based on prompts, a sort of Text RPG game. I finished the UI, so now I ...
2
votes
1
answer
214
views
ProducesAttribute does not filter requests in ASP.NET Core Web API before code is executed
Problem
I have an ASP.NET Core Web API that can produce XML and JSON responses. For one of my controllers, I allow producing both XML and JSON. However, for all other endpoints, I only want to produce ...
1
vote
0
answers
38
views
StatusPages won't use route installed ContentNegotiation plugin
I'm trying to add a GraphQL route.
This route has a custom ContentNegotiation plugin, which forced me to move the installation of the global ContentNegotiation plugin from Application to root Route (...
0
votes
1
answer
439
views
receiveParameters() fails in ktor
In the ktor app, I'm trying to read posted parameters like this :
val params = call.receiveParameters()
But I'm facing this error :
No Default Transformations found for class io.ktor.utils.io....
0
votes
0
answers
598
views
I'm facing a 404 Not Found error when trying to register a user in my Ktor application
When sending a POST request to register a user using Postman, a 404 Not Found error is encountered. The Ktor server logs indicate a failure in resolving routes with the message: "No matched ...
2
votes
1
answer
1k
views
Ktor response negotiation error in case of unexpected response
Using Ktor's ContentNegotiation is very convenient and easy way, how to de-/serialize text into one's preferred format.
In our case it is JSON.
All the guides on the internet (server or client) will ...
2
votes
1
answer
830
views
No Default Transformations found although everything seems to work
I know there are several posts about it, from people that initially didn't know how to configure the ContentNegotiation either on server or client. But I have read all the docs and I have configured ...
2
votes
0
answers
118
views
Best Practices for HTTP Content Negotiation in case of Error Responses?
I have a discussion, how to implement content negotiation for error cases. I'd like to hear your opinion or experiences to deal with this topic. Please be aware that there might be APIs dealing with ...
0
votes
1
answer
121
views
How to config default return type Spring Boot
is there any way to make default content type?
i use this
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.ignoreAcceptHeader(true)....
1
vote
0
answers
60
views
Ktor Framework using content negotiation with framemaker
New to Kotlin and Ktor. I generated Ktor app using both Jackson Serialization and Framemaker. I allowed sample code to be included.
Using Chrome browser and accessing the endpoint returning text ...
1
vote
1
answer
820
views
How to configure Apache 2.4 to use 'content negotiation' in order to serve webp images?
In my HTML file there are several <img src="images/<filename>.jpeg">
The directory "images" holds these files:
<filename>.jpeg
as well as
<...
0
votes
1
answer
598
views
How to support content negotiation with Actix Web?
My Rust Actix Web application provides multiple routes to the same resource with different content types. The example below works fine with curl localhost:8080/index -H "Accept:text/html but not ...
1
vote
0
answers
107
views
Array of strings property of my class is not coming up in the csv
I am using CsvHelper (ver: 27.2.1).
I have a Get API and i am trying to enable text/csv Accept header. So that when I initiate a Get Request from Postman with Accept header as text/csv, I get a CSV ...
0
votes
1
answer
1k
views
Spring boot same API but different return type of byte[] and json
I want the capability to send the JSON list like List if the request Accept Header is of type application/json, but send it in a byte array(avro format) if the request Header is of type application/...
0
votes
0
answers
395
views
JSON with expanded table to CSV Formatter?
I have been developing an api in c# asp.net with table relationships returning a json format as default and I'm added a custom csv formatter from WebApiContrib.Core.Formatter.Csv
my problem is that ...
0
votes
0
answers
322
views
How do I serialize a response as JSON+LD using Flask-Arrest?
I am working on a simple Flask app that has a single route that allows GET requests.
If the incoming request header specifies application/json+ld in the request header, I want to return JSON-LD.
As of ...
1
vote
1
answer
567
views
net/http: Does DetectContentType support JavaScript?
DetectContentType, JavaScript support ?
https://github.com/golang/go/blob/c3931ab1b7bceddc56479d7ddbd7517d244bfe17/src/net/http/sniff.go#L21
Is there a genuine reason behind the http Method ...
0
votes
1
answer
306
views
Spring throws HttpMediaTypeNotAcceptableException inexplicably
I have my Spring app configured to use a GET parameter for content negotiation. Code is Kotlin but would work the same in Java.
Config:
override fun configureContentNegotiation(configurer: ...
3
votes
1
answer
1k
views
How to serve compressed content without caching in AWS Cloudfront with API Gateway origin?
I'm using Cloudfront distribution with Regional API Gateway origin. For endpoints, for which I can't use caching, I still need the response body to be compressed, if request includes "Accept-...
2
votes
1
answer
182
views
When serving a single-page application that uses the History API, should HTTP content negotiation be used?
When serving a single-page application (SPA) that uses the History API, it's common practice to serve the application's HTML instead of a 404 response for requests to any unknown resource. If the ...
1
vote
2
answers
1k
views
.NET Service reference sending wrong accept header (text/plain)
I've created an ASP.NET Core web application, and installed + used the Swashbuckle.AspNetCore version 6.1.5 Nuget package. This hosts the following openapi document on https://example.com/swagger/v1/...
0
votes
2
answers
274
views
Spring content negotiation - one mime type to extend another
I'm using Spring Boot with header based content negotiation.
I have one set of endpoints that are only available to a subset of clients, and the rest are public.
My public endpoints are annotated like ...
0
votes
1
answer
4k
views
Unsuccessful content negotation with excel file
I have a Spring Boot application with an already working endpoint that produces an xlsx file.
Now, I want to implement content negotation on this endpoint but I always receive 406 Not Acceptable.
{
...
1
vote
1
answer
113
views
Can you add a Browsable API into an ASP.NET application?
The Django web framework has a Browsable API and I would like to implement something similar in my ASP.NET (with ReactJS) application. Essentially, suppose that there's an API endpoint called api/test;...
0
votes
2
answers
2k
views
How do you configure spring boot 2 to return xml by default?
To start with I've read this:
Spring boot - setting default Content-type header if it's not present in request
The older version of this worked on spring boot 1. However when receiving request ...
0
votes
0
answers
253
views
Strange behavior of content negotiation concerning SPARQL CONSTRUCT query
When issuing a SPARQL CONSTRUCT query to a specific endpoint, Apache Jena library 3.14.0 issues an error message as follows.
Endpoint returned Content Type: application/sparql-results+xml which is ...
3
votes
1
answer
4k
views
Ktor returns 415 from endpoints where receive() is used with ContentNegotiation
I have parameter classes with the @Searializable annotation:
@Serializable
data class ShowPostURL(
val date: String,
val titleSlug: String,
override val redirectTo: String? = ...
0
votes
1
answer
350
views
How to Gracefully Throw Exceptions in Custom Content Neogtiation Formatters in .NET Core
So I am building out a custom content negotiation formatter like this for a custom data format that we need to use in our .NET Core API.
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft....
-1
votes
1
answer
863
views
Ignore accept header in Spring REST WS
I have something like this:
@RestController
public class MyController {
@GetMapping("/myAddress")
public Response generateReportAsync(...) {
...
}
}
This web service generates ...
1
vote
1
answer
451
views
Is there better approach to Accept Header based content negotiation in Spring API?
I am using Content Negotiation to define multiple response for the same REST API function , by changing the accept header.
Accept header : application/json , should give response as json (used by ...
1
vote
0
answers
496
views
Swagger and content negotiation configuration not working together
In my spring boot application, I have swagger configuration and content negotiation configuration. For the swagger to work, I need to comment out content negotiation. How to fix this? Thanks for your ...
0
votes
2
answers
901
views
HTTP header to return server available content types
E.g. Suppose we have a restful API endpoint to return orders, that can output in different formats.
[GET] /orders/42
that could return xml, json or pdf.
I thought that the best option, in a restful ...
3
votes
2
answers
2k
views
How to disable content negotiation for Spring Actuators?
I'd like to disable Content-Negotiation when actuator endpoints /info and /health are called
here is my configs file
@Configuration
public class InterceptorAppConfig implements WebMvcConfigurer {
...
0
votes
1
answer
2k
views
How to make Spring boot CSV message converter display CSV inline and not download when using a browser
I created a spring starter project in eclipse . Most of the code was from this link https://www.logicbig.com/tutorials/spring-framework/spring-web-mvc/csv-msg-converter.html.
I added content ...
0
votes
2
answers
369
views
Rest with spring-boot : Content Negotiation failed! No converter found for return value of type
I am trying to get the content of a java POJO on the browser in JSON format using spring-boot 2.1.9 and spring REST. Very basic example! But I get the exception shown on the title of this post. When I ...
3
votes
0
answers
437
views
How to set default response format in spring-mvc using 'Content Negotiation Manager' when invalid format is given?
I wanted to get response from spring-mvc-controller either in json or xml format depending on the parameter - 'format' in the URL. I am able to achieve this using ContentNegotiation as shown in below ...
1
vote
1
answer
577
views
nginx Http2 Push fails when Vary: Accept header set
Basically, http2 push using http2_push_preload doesn't work if you set header Vary: Accept on your response because you are doing content negotiation using the Accept request header. I'm using content ...
0
votes
2
answers
2k
views
How to establish a custom xml serialization with content negotiation in spring boot 2
I'm refactoring a REST-API and want to add content negotiation to it. That works so far.
Now I tried adding a custom xml serializer for all requests. But it is not or not properly called.
The ...
0
votes
1
answer
2k
views
spring-boot test: @get request returns with body null
while doing Content-negotiation testing mock GET returns with null in response body although response status is 200.
java.lang.AssertionError: Response header 'Content-Type'
Expected :application/...
1
vote
0
answers
2k
views
How to Sort/Order/Prioritise HttpMessageConverters in SpringBoot 1.5.x
I need to support XML and JSON in one of my spring-boot 1.5.12 service and the following dependencies on classpath
jackson-dataformat-xml
jackson-json dependencies(shipped as part of spring-web ...
3
votes
1
answer
2k
views
Is it possible to merge two json responses using nginx?
I have an existing express endpoint that looks like this:
app.get(`${route}/:id`, async (req, res) => {
try {
const id = req.params.id;
const result = await dbFn(id);
...
0
votes
1
answer
204
views
Web API content negotiated formatters with accept header and url parameter
I have implemented content negotiation so that a specific serializer will be used based on the accept header:
XmlFormatter fmtXml = new XmlFormatter();
fmtXml.SupportedMediaTypes.Add(new
System.Net....
2
votes
2
answers
4k
views
How to set priority to Spring-Boot request mapping methods
I have a Spring-Boot (v2.0.2) application with a RestController with 2 methods which only differ by the Accept header. A simplified version of the code is this:
@RestController
@RequestMapping("/...
0
votes
1
answer
2k
views
Spring Server Error on unknown Accept header
I have a Spring REST project that uses spring boot. I have declared jackson-dataformat-xml as a dependency in maven to support xml when the accept header is application/xml (and it natively accepts ...
1
vote
0
answers
354
views
How to stream Http response with custom response formatter?
I have a REST controller that streams the response in csv format using a helper method like below:
public static void CsvStreamHelper(IEnumerable<T> data, Stream stream)
{
using (var writer ...
0
votes
1
answer
41
views
Should an HTTP server respond with a more specific Content-Type than was requested?
For example, if the request was
GET /feed.xml HTTP/1.1
Host: www.nowhere123.com
Accept: application/xml
... would it be admissible for a server to respond with a header Content-Type: application/atom+...
2
votes
1
answer
970
views
Spring Boot manual content negotiation
I'm reworking old rest api and need to keep compatibility with it. Old api uses servlets and works with both xml and json. The logic is following:
it checks 'Content-Type' header, if it's supported ('...
1
vote
0
answers
61
views
How to use asp.net WebApi Content Negotiator with asp.net MVC?
I'm using asp.net MVC in combination with React.
My website composites from 2 parts, one for views that return React components, and another for doing works such as creating new object, logging in and ...
0
votes
1
answer
724
views
Controller returning inputstream - content negotiation and media types
Introduction
I have a question about a RestController and a Test .
I have the following PostMapping:
@PostMapping(path = "/download/as/zip/{zipFileName}" )
@ResponseBody
public ...
0
votes
1
answer
2k
views
Generate PDF / XLSX files as attachments to REST API
Requirement is to generate pdf / excel document on hitting the REST API endpoint.
i.e. localhost:8080/download.xlsx -> generates a file with data in .xlsx format
localhost:8080/download.pdf -> ...