Hi everyone, how are you?
I have a question about how to show a specific HTTP Response Header value in notification message after the Update with Data Manipulation Plugin.
I’m checking with a NodeRED workflow, before start the processing of the API Call, if the analyst complete a value in a variable in Grafana. If not, I’m answering with a 404 HTTP response, with a header, called “ticket”:

What I want is to show the value of that “ticket” header, “No Ticket”, in the notification message in Grafana, after I press the button that execute the Update. For that I put this in the Custom Code box of the Update:
But I’m getting this:

And I want “An error ocurred sending IOCs: No Ticket”
I’m sure that there is a way to access to a specific Response Header value, but I don’t know how.
Anyone know?
Thanks in advance for your help.
1 Like
@mikhailvolkov , any clue about this question? Maybe I can do it with Custom Code like I solved obtain field/element values in the past, but I’m a little rusty after a year not “playing” with Data Manipulation Plugin
, and maybe is simple what I’m asking.
Thanks in advance.
1 Like
@alejandroguida response.headers
is a object with properties.
You should be able to display it like ${response.headers.ticket}
if it’s returned correctly.
Hi @mikhailvolkov , how are you?
Thanks for your answer.
${response.headers.ticket}
was the first that I tried, with no luck, 
I can confirm you that the Header “ticket” is being received in the Headers Response:
So I don’t know what could be happening
Hi @mikhailvolkov , how are you?
Continuing with the troubleshooting of this, I added the console.log(response) in the Custom Code, and review Console tab with Dev Tools of the Browser, additionally to the Network tab.
As you can see, even that at the Network tab you have the Response Header {"Error": "Please add a Ticket ID"}
, and you have the Response Body {"error":"Enter Ticket ID"}
, you don’t have that in the Headers or in the Body in the Console tab:
I understand that to be usable by Data Manipulation Plugin, the value need to be there. For example, I tried with “type” field (“cors” value) as a test, and it showed in the error message:
So, at the end, is there any options that you know to customize the error message with a specific text that you can provide, based on the response?
Thanks in advance, and sorry for the long explanation.
@alejandroguida Did you find an answer to your question? If not, please open an issue in GitHub repository.
Hi @mikhailvolkov,
No, I didn´t find a solution for this, it was imposible to capture and use a Response Header with Data Manipulation Plugin.
Give a couple of hours and I can open an Issue on GitHub.
Regards,
Alejandro
@alejandroguida Please do, I will ask my team to guide you.
1 Like
I followed vitPinchuk’s guide here and it worked 
It was necessary to set Access-Control-Expose-Headers
(Node-RED example):

And access necessary header via context.panel.response.headers.get()
in Custom Code of Update Request section:
if (response && response.ok) {
notifySuccess(['Test command', 'Success']);
locationService.reload();
} else {
notifyError(['Test command', 'Error: ' + context.panel.response.headers.get('errmsg')]);
}
Result:

2 Likes