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

GetResponseHeaderField working postman

is this supposed to be working in postman?

Response = HTTP_Services('GetResponseHeaderField', 'Content-Length')

Comments

  • How do you mean "working in postman"? What, ultimately, are you trying to do?
  • I was trying the command I posted. But it was in a GET method, I now assume it would only โ€˜workโ€™ in a POST / PATCH method. Work = get a value in response returned.
  • edited March 2022
    Are you trying to get the value of the Content-Length header in your API from what Postman is sending you or are you trying to set the Contet-Length header in your API and see the results in Postman after the API call is finished?
  • Sorry, is convoluted, it was just a test verification.
    I was just checking an idea that I could preset known values that I need in a POST.
    So, at the end of a GET I did a setResponseHeaderField and to test if I could get it back I did a GetResponseHeaderField which did not return a value, so I did the Response = HTTP_Services('GetResponseHeaderField', 'Content-Length') to see if anything was working.
  • I'm still having a bit of difficulty following you, but I think what you are trying to do is:
    • Use Postman to send a request to an API.
    • In this request you have the Content-Length header set to a value (although Postman normally sets this value for you..but that is another discussion).
    • Then in your API you are trying to determine the value using the GetResponseHeaderField service.
    If I am remotely correct, then you should be using the GetRequestHeaderField service instead. If I am not correct, please give me a little more detail.
  • Just testing.
    In my api at the end I do:
    http_services("SetRequestHeaderField","TESTING","ThisIsATest")

    I see it in the postman headers at the top (where the authorisation is)

    at the start (2nd time) I do:
    ThisKey = http_services("GetRequestHeaderField","TESTING")

    I have no value returned.
    Am I only allowed to set/get the keys that are standard (i.e. the ones that are there / show up in the meta data call tip?

    How can I set values that are 'global' for the duration of the web session.?
  • In my api at the end I do:
    http_services("SetRequestHeaderField","TESTING","ThisIsATest")


    This is not a service you should be using. This exists purely for the benefit of the HTTP Framework so that it can take the incoming request headers from the client (e.g., Postman) and store them early on so that in your API code you can use the GetRequestHeaderField to read the value and use it as you see fit.

    I see it in the postman headers at the top (where the authorisation is)


    Are you saying you created a header in the Postman request called TESTING and gave it a value of "ThisIsATest"? Is this what you are trying to observe in your API code?

    at the start (2nd time) I do:
    ThisKey = http_services("GetRequestHeaderField","TESTING")

    I have no value returned.


    What do you mean "2nd time"? Do you mean the 2nd time you submit the request from Postman?

    Am I only allowed to set/get the keys that are standard (i.e. the ones that are there / show up in the meta data call tip?


    You can set custom headers but you have to define them first in the Registry entry for OECGI4. See this article.

    How can I set values that are 'global' for the duration of the web session.?


    This depends on how you define "web session". Normally this means one request and one response. In this context, if you set a request header then that value will remain constant during the execution of your API until you send back a response.

    If by "web session" you mean from the time a user logs into your web-based application until the time your user logs off of your web-based application, then that is something you must implement on your own. The communication protocol of the web, HTTP, is stateless, which means it does not maintain values from request to request, etc. One way to overcome this is through a cookie. See the SetCookie service. Another way to overcome this is to create your own sever-side session manager. This would be an OI application running on the server that tracks traffic coming in and looks for identification, such as the Authorization header or a cookie, to associate with a record you maintain.
  • Are you saying you created a header in the Postman request called TESTING and gave it a value of "ThisIsATest"? Is this what you are trying to observe in your API code?


    Is there by doing this in my api:
    http_services("SetRequestHeaderField","TESTING","ThisIsATest")


    What do you mean "2nd time"? Do you mean the 2nd time you submit the request from Postman?


    The first time the SetRequestHeaderField woild be set at the end so, no value would be expected by the GetRequestHeaderField at first execution until executed again (2nd time)

    FYI:
    this was set in my api and is still there when a resonse is returned.



    Anyway, I am obviously not up to speed with how this is all supposed to hang to-gether, so obviously any result I am not getting from now on I know it must not be allowed, so I will try another way.
    Just trying to retrofit/convert a inet_ html proc
  • This looks like a forest for the trees problem Baz. Have a rest and revisit with fresh eyes.
    Is there by doing this in my api:
    http_services("SetRequestHeaderField","TESTING","ThisIsATest")


    That doesn't happen and your image doesn't show it. That call assigns two OI variables, nothing more. They're common variables so you can retrieve it at anytime within the processing of the request but it has no effect on anything external to the immediate OI session. Postman will never be aware of it.

    With your morning fresh eyes you might notice that the request header in Postman is "TESTIT" not "TESTING".
    I'd take a punt and say that you manually added "TESTIT" as a header in some previous test. If you're using the same request it will stick around.
  • @BarryStevens - It seems like you are trying to send a request header from your API back to Postman. If so, then that is not how HTTP works. If you haven't already, read the HTTP article from our help. But if I can simplify this:

    All HTTP calls begin with the client sending a request to the server. In this request, the client can send the following:
    • One HTTP method
    • Zero or more request headers and values.
    • A request body.
    All HTTP calls end with the server sending back a response to the client. In this response, the server can send the following:
    • A status code.
    • A status description
    • Zero or more response headers and values.
    • A response body.
    I think you are getting confused in thinking that HTTP calls are like functions in OI, where you can pass arguments back and forth. In this case, you are treating headers as if they were arguments. In a sense they are, but they only go in one direction.
  • Ok, I see my mistake.

    Zero or more request headers and values.
    A request body.">

    I dont really want to set a value from my api, just get a value from the GET method sent, from the REQUEST header.
    I still cant get my TESTIT value by doing ThisValue = http_services("GetRequestHeaderField","TESTIT")
    and I just see the standard ones in here RequestHeaderFields =http_services("GetRequestHeaderFields")
  • Did you update the Registry to support your customer request header?
  • Ah, now I get it. Don't remember having to do that. I saw the reference earlier, but was not sure what I was looking for.
    I thought, in the first instance, the additionalvalues was your routines somehow.

    Now all good, but, now I have to remember, dont delete this conversation. ๐Ÿ˜
Sign In or Register to comment.