Forum Discussion

rfortune's avatar
rfortune
Contributor
16 years ago

Empty TEMPLATE in resource endpoint causes request to fail

Hi there

I have a generic endpoint that I'm writing tests against: http://api-proxy.web/api.xro/2.0/{endpoint}/{ID}

I defined the base of the endpoint in my Service Endpoints section. I then defined a parameterized resource path as follows:
api.xro/2.0/{endPoint}/{ID}

The idea being that I can have generic methods against a URL and then specify the final endpoint in the test.

When I use the above setup it works fine so long as I provide data for each of the Templates e.g. {endpoint} and {ID}

However ID is optional and only used when I am looking for a specific item, in this case an invoice.

If I leave the {ID} Template blank it the request fails to generate correctly and appears as the following in the Raw view:
"GET null HTTP/1.1"

Where as if the ID Template is provided the request forms perfectly:
"GET http://api-proxy.web/api.xro/2.0/Journa ... e5b66f0abb"

Is there a work around or a way for me to meet my goals? Rather than supplying the item ID as a Template, is there an optional way of passing in such a parameter?

7 Replies

  • Hello,

    if you set endPoint and ID as project properties and use property expansion than if you leave ID empty it will actually be empty string not null. And you reference them as ${#Project#endPoint}/${#Project#ID}

    hope this helps,
    robert
  • Cheers - I use dynamic expansion elsewhere, so no hassle in implementing this recommendation.
  • BTW, this approach, Project level will not work for individual test cases as the values I wish to use will be local and valid for one one particular testcase at a time. I have put a testcase parameter in to cater for this.
  • Hi Robert,
    I'm having difficulty implementing the approach you suggest above. Could you take a look at the attached project and tell me why the dynamic replacement isn't taking effect?

    Cheers,
    Richard

    I'm using the latest nightly(09/11/2010) of the SOAPUI Pro
  • Hi!

    Could we have a quick jump back to the original post? You said that if you didn't specify a value for the ID template parameter the GET URL comes out as NULL in the Raw request view?

    This sounds like a bug to me. Can you reproduce that and check for any errors in the error-log?

    regards!

    /Ole
    eviware.com
  • Hi Ole,
    {apologies for the delay in getting back to you - the workaround solved the problem I was facing initially. But looks like I do need to be able to do what it was I was trying to do originally. so here's the dump and quite likely the root of the issue.}

    here is the dump:

    Tue Nov 16 11:01:11 NZDT 2010:ERROR:org.apache.commons.httpclient.URIException: escaped absolute path not valid
    org.apache.commons.httpclient.URIException: escaped absolute path not valid
    at org.apache.commons.httpclient.URI.setRawPath(URI.java:2837)
    at org.apache.commons.httpclient.URI.parseUriReference(URI.java:2023)
    at org.apache.commons.httpclient.URI.<init>(URI.java:147)
    at org.apache.commons.httpclient.HttpMethodBase.getURI(HttpMethodBase.java:265)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.BaseHttpResponse.<init>(BaseHttpResponse.java:75)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.SinglePartHttpResponse.<init>(SinglePartHttpResponse.java:42)
    at com.eviware.soapui.impl.wsdl.submit.filters.HttpPackagingResponseFilter.httpRequest(HttpPackagingResponseFilter.java:78)
    at com.eviware.soapui.impl.wsdl.submit.filters.HttpPackagingResponseFilter.afterAbstractHttpResponse(HttpPackagingResponseFilter.java:44)
    at com.eviware.soapui.impl.wsdl.submit.filters.AbstractRequestFilter.afterRequest(AbstractRequestFilter.java:64)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.sendRequest(HttpClientRequestTransport.java:211)
    at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:123)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Tue Nov 16 11:01:11 NZDT 2010:ERROR:org.apache.commons.httpclient.URIException: escaped absolute path not valid
    org.apache.commons.httpclient.URIException: escaped absolute path not valid
    at org.apache.commons.httpclient.URI.setRawPath(URI.java:2837)
    at org.apache.commons.httpclient.URI.parseUriReference(URI.java:2023)
    at org.apache.commons.httpclient.URI.<init>(URI.java:147)
    at org.apache.commons.httpclient.HttpMethodBase.getURI(HttpMethodBase.java:265)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:383)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.sendRequest(HttpClientRequestTransport.java:194)
    at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:123)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)