Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

SetResponsetHeaderField

HTTPClient_Services('SetResponsetHeaderField',"ACCOUNT","LAN")

I dont see header set here in POSTMAN:


So, what am I still missing.

Comments

  • Assuming your code snippet is copy/paste, you have a typo in the name of the service.
  • edited April 2022
    Oh, like they say - another pair of eyes .

    thank you, thank you - so sorry
  • No worries. I'd like positive confirmation that it does work as we expect when you get a chance.
  • I'm also curious that you got a misspelled service. Are you using the SRP Editor to auto-list and autofill your service names?
  • HTTPClient_Services('SetResponseHeaderField',"ACCOUNT","LAN")

    Still dont see it in the response header
  • To rule out your own coding interference, try updating the Ping API like so:

    API ping.GET HTTP_Services('SetResponseHeaderField', 'ACCOUNT', 'LAN') Properties = 'currentDateTime' Values = SRP_DateTime('Format', SRP_DateTime('Now', True$), "DDD, DD MMM YYYY hh:mm:ss 'GMT'") objResource = HTTP_Resource_Services('AddProperties', '', Properties, Values) Rels = 'self' : @FM : 'apiEntryPoint' URLs = FullEndpointURL : @FM : APIURL HTTP_Resource_Services('AddLinkRelations', objResource, Rels, URLs) If Error_Services('NoError') then // Serialize the object into a JSON string. jsonResource = HTTP_Resource_Services('GetSerializedResource', objResource) // Set the response body with the JSON string and set the Content-Type response header. HTTP_Services('SetResponseBody', jsonResource, False$, 'application/hal+json') end else HTTP_Services('SetResponseError', '', '', 500, Error_Services('GetMessage'), FullEndpointURL) end end api

    Then test this API in Postman. Here's what I get:



    If this still fails, there could be a problem with your web server filtering out non-standard request headers.
  • Changing to HTTP_Services it now works in my code also.

    >>I'm also curious that you got a misspelled service. Are you using the SRP Editor to auto-list and autofill your service names?

    I would have had SetRequestHeaderField when trying to get work and then edited it to change to 'Response' (but badly)
  • The real problem was that you were using HTTPClient_Services, so the SRP Editor could not have auto-filled that for you. I missed that you were using the wrong module.
  • if I do:
    HTTP_Services('SetResponseHeaderField', 'ACCOUNT', 'LAN')

    Is there a further setting that I or the WEB Developer needs to do to be able to read this in the header.
  • Sorry to answer a question with a question, but did you not see this in Postman?
  • Yes, but the web developr says he can see it in postman, but not in his web application and he said I would have to do this:

    HomeURL = HTTP_Services('GetHomeURL')
    HTTP_Services('SetResponseHeaderField',"Access-Control-Expose-Headers","ACCOUNT,WWW-Authenticate")
    HTTP_Services('SetResponseHeaderField',"Access-Control-Allow-Origin",HomeURL)

    Just upgrading now and will see how it goes.
    I think he is missing something at his end, but, what do I know.!!
  • Bit of a sledgehammer to crack a nut, so, just setting a value in the login api json will suffice.

    All good now.
  • Ah, yes. He is dealing with CORS.
  • would that then cause an issue with attempting these options:

    //it looks like this gets from response header//
    DataPath=HTTP_Services('GetHTTPCookie', CookieName)

    //if DataPath empty, check if can get from request header//
    MyCookies = http_services('getRequestHeaderField','Cookie')

    I do this to set it:

    HTTP_Services('SetCookie', CookieName, DataPath)
  • Not sure. I don't think I'm seeing enough of your solution to render a valid opinion.
  • Ok thanks.
    Not a deal breaker. I initially read a control file to get the data folder location to attach, so, I thought if I could then 'save it' I would not need to read again. (just a little i/o save)

    You must require access to the request headers, so, I think this could work.
    MyCookies = http_services('getRequestHeaderField','Cookie')

    I have put a temporary trace in to see which is working when he does his testing.
    Here is my code for that section:

    // dont use registry additionalvalues as could break future use by oecgi4 /// DataPath =null$ CookieName ='pbcdatapath' pbcdatapath = HTTP_Services('GetHTTPCookie', CookieName) oswrite pbcdatapath to 'c:\temp\pbcdatapath':RTI_CreateGUID():'.txt' if pbcdatapath then DataPath = pbcdatapath[-1,'B='] end else MyCookies = http_services('getRequestHeaderField','Cookie') oswrite MyCookies to 'c:\temp\MyCookies':RTI_CreateGUID():'.txt' if MyCookies then convert ';=' to @fm:@vm in mycookies For Each Field in mycookies using @FM if Field<0,1> _eqc CookieName then DataPath = Field<0,2> end CookieFields<-1> =Field<0,1> CookieValues<-1> =Field<0,2> Next Field end end
  • FYI:

    this worked:
    pbcdatapath = HTTP_Services('GetHTTPCookie', CookieName)
  • I don't see any significant difference between this code and your previous code.
Sign In or Register to comment.