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

url with port number issue

url calling the myapi:

http://clientweb.com.au:8081/fes-api/myapi/login

returning values, the ParentUrl = http://clientweb.com.au/fes-api/myapi/workorder?date=30/6/2022

i.e. the :8081 is getting stripped

Is there any setup that will fix this issue.
(sorry if I am supposed to find in the documentation)

Comments

  • I thought this might be the override solution:



    But according to the i

  • As noted in the help text you posted, the Home URL you see in the Setup window is only used when "one cannot be derived". Let me explain exactly how this is derived.

    The HTTP Framework relies upon data coming in through the Request dynamic array that the OECGI passes through. In position 19 of that array, which is called HTTP Server Name, the URL used to make the request is stored. This is where we derive the URL. Likewise, in position 20 of that array, which is called HTTP Server Port, the port number used to make the request is also stored.

    The problem is that the HTTP Server Name does not include the port number even if the client specifies it. Thus, the Request dynamic array looks the same whether the specified URL looks like this:

    http://clientweb.com.au

    or

    http://clientweb.com.au:80

    Both would look like this in the Request dynamic array:

    <19> clientweb.com.au
    <20> 80

    I realize that in your case the port is 8081. However, the Framework has no way of knowing whether this port was appended in the URL originally so it doesn't know to append it to any URLs that are sent back in the response.

    You can add code to force this if you want, but this would be a custom change that should be done in a localized copy of the relevant routines.
  • Ok, what I can do is assemble my own ParentUrl (I assume I should not change the one you pass in) from the "Home URL" and "API URL" checking if there is an 'override' value in the "Home URL" first (making it site independent)
  • I would update the API_SETUP insert with new variable called FullEndpointURLPort and assign it like this:
    FullEndpointURLPort = HTTP_Services('GetFullEndpointURL') : ':' : HTTP_Services('GetHTTPServerPort')
    Then you can use your flag to determine if various routines should use FullEndpointURL or FullEndpointURLPort when building the response.
  • Thanks.
    I have gone this way which works for me and can see what is happening in one place.
    SaveParentUrl =ParentUrl HttpSetupKey = SetupRowKeyID$:"*":OIAccount HttpSetupRecord =xlate(SetupTable$,HttpSetupKey,'','X') HttpSetUpUrl = HttpSetupRecord<HTTP_FRAMEWORK_SETUP_HOME_URL$> if len(HttpSetUpUrl) then HttpSetupApiUrl =HttpSetupRecord<HTTP_FRAMEWORK_SETUP_API_URL$> if HttpSetUpUrl[-1,1]='/' then HttpSetUpUrl[-1,1] ='' end ParentUrl =HttpSetUpUrl:HttpSetupApiUrl:'/':"myapi" end
  • That way will work and it is similar to the original way the Framework derived the Home URL. However, it was pointed out to me that API sites that support multiple URLs will always be returning a hard-set URL rather than the one actually used to make the request. This might not be a problem for your implementation, but we had to account for the most flexible scenario.
  • edited July 2022
    "safer" version
    SaveParentUrl =ParentUrl HttpSetupKey = SetupRowKeyID$:"*":OIAccount HttpSetupRecord =xlate(SetupTable$,HttpSetupKey,'','X') HttpSetUpUrl = HttpSetupRecord<HTTP_FRAMEWORK_SETUP_HOME_URL$> if len(HttpSetUpUrl) then NoUrlParentUrl =field(ParentUrl,'/',4,len(ParentUrl)) ParentUrl =HttpSetUpUrl:"/":NoUrlParentUrl end
Sign In or Register to comment.