NetTalk Central

Author Topic: How to change header of the ANSWER in an API rest server  (Read 1554 times)

jlavera

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
How to change header of the ANSWER in an API rest server
« on: January 26, 2025, 11:06:08 AM »
Hi, All.

I set up a rest server that will be consumed by a third party. It works fine, but in the header our server returns "application/json; charset=utf-8" (see attached image).
I need it to be just "application/json", but I cannot find where this is generated or how to change it!
There is no hand code, no security, nothing really yet, just a single method to answer a pseudo "ping", like
WebServer -> WebHandler -> MyServer -> Ping

When I call as a client, I use something like net.CustomHeader = 'Content-Type: application/json' to set exactly this, but I kind of missing where something like this goes for the server to put in the ANSWER to the client.
I bet it is simple, but I cannot find anything about it. Can anyone help?

(Latest Clarion 11.1, latest Nettalk 14 versions).

Kind regards,
Jorge Lavera





jlavera

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
Re: How to change header of the ANSWER in an API rest server
« Reply #1 on: January 26, 2025, 12:23:23 PM »
I will answer myself, since I found the solution (ant it -was- easy, may help others.

Inside the method, there is a
BuildResult  routine
In there, the reply content type is set.
At the end of it, I added
p_web.ReplyContentType = 'application/json'
And I got exactly what I needed.

Kind regards,
Jorge Lavera
« Last Edit: January 29, 2025, 04:24:18 AM by jlavera »