Forum Discussion

DLuks's avatar
DLuks
Contributor
15 years ago

Rest service no param name and ampersands

Say I have a DataSource that has a column with a string delimited by ampersand. I want that piece to go into my URL. Is there a way to do this?

The two issues are, the test request method must have a field to put the parameters into it, but this field must have no name so I can simply input the string.

Second issue is the conversion of ampersands. How do I avoid that.

6 Replies

  • Hi,

    try adding a property-expansion in the URL itself referring to the DataSource property; also make sure the "entitize values" setting in the datasource options dialog is not checked.

    Does that help?

    regards,

    /Ole
    eviware.com
  • Well entitize values is already turned off, so I'm not sure that is helping.

    Let me give you some more background info so you can help me:

    I'm using a Rest method, with a Datasource, TestRequest, Datasource Loop in my TestCase.
    The column in my Datasource is a filter query string for our SearchAPI and there can be multiple of these separated by ampersands.

    Say I have property1 & property2 within my search index. A filter query can be achieved by doing ?q=blah&_property1=foo&_property2=foofoo

    A filter query parameter is dynamic in name, but has an appended underscore to the front of it.

    I would like my TestRequest to be able to insert the &_property1=foo&_property2=foofoo string onto the query part of my REST method.

    Basically there is no predefined method parameter name (since they can be dynamic) and the string should be able to contain ampersands.

    Is there a way to alter the outgoing URL during the TestRequest step? I could achieve this feature that way if there is...
  • I do understand where you are getting at with the property expansion in the URL, but how do you do that from a test case?
  • Hi,

    just modify the url to contain the property-expansion, for example

    http://my.host.com/someurl?${#TestCase#queryString}

    which would look for a "queryString" property in the testcase (populated with a groovy script for example) and expand it into the URL

    in other contexts the property-expansion would just expand to an empty string.

    Does that make sense?

    regards,

    /Ole
    eviware.com
  • The issue with doing it this way, is that the url is defined with query properties also. If one of those happen to be filled it, it will append two ??'s to the url string. I think I have found two solutions...Either the way you defined where every property is a template, but that seems like a hassle.

    The other way is to :

    testStep = context.testCase.getTestStepByName((String)"TestRequest")
    testStep.prepare(testRunner, context)
    /*
    Modify URL by appending the text from my datasource
    *
    testStep.run(testRunner, context)

    Havn't figured out that part yet though.