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

Cookies issue

My Test Code:

Name ='pbcdatapath'
xpbcdatapath = HTTPClient_Services('GetCookie', Name)
xMyCookies = http_services('getRequestHeaderField','Cookie')
xMxCookies = HTTPClient_Services('GetResponseHeaderField', 'Set-Cookie')

reqitry - additionalvalues has:
HTTP_AUTHORIZATION,HTTP_MEDIA_TYPE,HTTP_ACCEPT_ENCODING,HTTP_ACCEPT_CHARSET,HTTP_ACCEPT_LANGUAGE,HTTP_DEBUG,HTTP_COOKIE

Re code above:


xpbcdatapath is null
xMy ookies returns correct values
xMxCookies is null , which is why dpbcdatapath is null (called by HTTPClient_Services('GetCookie')

Here is POSTMAN:
Request header:


Response header:



Am I missing something here?

Comments

  • I'm not following. What specifically is the issue?
  • xpbcdatapath = HTTPClient_Services('GetCookie', Name)

    Does not return a value and it should
  • Thank you for clarifying. Upon review you did explain this, but my eyes were getting crossed because I'm trying to make sense of which direction your requests and responses are going. I think I know what the problem is, but I want to make sure I understand what you are trying to do. Is the following correct:
    • You are using Postman to send an API request to an API you programmed in the HTTP Framework.
    • In this Postman request, you are setting the value for a cookie.
    • In your API, you are trying to get the value of this cookie.
  • Thank is correct
  • The problem is that you are using the HTTPClient_Services module within your API. This module should only be used for when you are using OI as an HTTP client to send API requests. In this context, the GetCookie service will tell OI what the API server is ending back.

    When you are programming within your own API code, stick with HTTP_Services. Use the GetHTTPCookie service. I don't blame for you being confused. The GetHTTPCookie service isn't obvious because it is a synonym to the GetHTTPValue service. But that should get you on the right path.
  • All good now, thanks - will obliterate HTTPClient_Services from my memory

    "...HTTP client to send API requests" ?
    example?
  • @BarryStevens
    STP

    Sending to or requesting data from external services
  • Thanks, thought that, just needed to have confirmed.
  • Ask Mark noted, that would be one example. In the presentation I gave at the 2016 Revelation User's Conference, I stressed the importance of our systems now being an interconnected web of APIs. Thus, for OI applications to fit into this world, it needed to provide best-practices and accepted solutions, such as REST APIs. But that door swings both ways. It also means OI needs to be able to call third-party APIs and understand how to consume their content. Thankfully the majority of APIs out there are RESTful and use JSON, but there are still a number of RPC and SOAP solutions so we should know how to use them as well.
Sign In or Register to comment.