I got this error message while trying to execute the get method.
Validation failed: Values not equal for element '$..userName', expected 'admin' but was '["admin",null,"HiCitrus","Unisys1","dscsc"]'
This is the script I have used:
http().client(todoClient)
.send()
.get("/rest/api/user/allusers")
.contentType("application/json");
http().client(todoClient)
.receive()
.response(HttpStatus.OK)
.messageType(MessageType.JSON)
// .validate(path, controlValue);
.validate("$..userName","admin");"
There are multiple parameters available for the username - is there a way to validate if I find the username "Admin"? Tried with the code below, but it's throwing an error.
.validate("$..userName",contains("admin"));
Related
I'm trying to add a lookup activity that will look up a series of values(companyIds) and insert the values into here
["/apiCore/api/countries","/apiCore/api/Metrics/MyLookup"]
At present my configuration looks like the following:
I was wondering if it was possible to add Lookup activity to insert the values as follows:
And then enter a parameter like #activity('MyLookup').output.value to:
["/apiCore/api/countries","/apiCore/api/Metrics/MyLookup"] so it change to:
["/apiCore/api/countries","/apiCore/api/Metrics/** #activity('MyLookup').output.value**"]
Can someone let me know if the above would work? If not, do you have any suggestions?
I got the answer to my suggestion with the following error:
{
"errorCode": "2200",
"message": "ErrorCode=HttpRequestFailedWithClientError,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Http request failed with client error, status code 400 BadRequest, please check your activity settings. If you configured a baseUrl that includes path, please make sure it ends with '/'.\nRequest URL: https://pm2.preqinsolutions.com/apiCore/api/Metrics/#activity('MyLookup').output.value.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.Net.WebException,Message=The remote server returned an error: (400) Bad Request.,Source=System,'",
"failureType": "UserError",
"target": "dynamoCompanies",
"details": []
}
You will notice the error is with:
#activity('MyLookup').output.value
here:
https://pm2.preqinsolutions.com/apiCore/api/Metrics/#activity('MyLookup').output.value.,
Any suggestions will be very much welcomed
Updated question
Using string interpolation, you can build the URL by adding the output of look up activity. Instead of using the URL as https://pm2.preqinsolutions.com/apiCore/api/Metrics/#activity('MyLookup').output.value, you can try the following:
I have taken a sample lookup which gives the following output:
Now, I have used a variable to build the URL value. I have taken the value /apiCore/api/Metrics/ in a parameter called relativeURL.
https://pm2.preqinsolutions.com#{pipeline().parameters.relativeUrl}#{activity('Lookup1').output.value}
This generates the required URL. When I call it in web activity, you can see the URL that is being passed in debug input (I don't have access to the activity fails).
below is the image of the dynamic body in Web activity wherein I am leveraging a pipeline parameter
With the above set of configuration and values, the web activity is successfully getting executed.
Now for the same REST API, I am trying to use it as source in dataflow :
with the same aspect of configuration and it is failing with below error :
Dataflow param:
Error:
ailure to read most recent page request: DF-REST_001 - Error response from server: Some({"error":{"code":"DatasetExecuteQueriesError","pbi.error":{"code":"DatasetExecuteQueriesError","parameters":{},"details":[{"code":"DetailsMessage","detail":{"type":1,"value":"The JSON DDL request failed with the following error: Invalid JavaScript property identifier character: }. Path '', line 1, position 7.."}},{"code":"AnalysisServicesErrorCode","detail":{"type":1,"value":"3239182519"}}]}}}), Status code: 400. Please check your request url and body.
Can someone please help what I am doing Wrong?
To use dataflow parameter within the expression builder, we have to concatenate the parameter with our data. Look at the following demonstration.
I am using derived column to show how to use parameters within expression builder. Using the dynamic content same as yours, I get the following output:
'{"queries":[{"query":"{$query}"}],"serializerSettings":{"includeNulls":true}}'
String interpolation does not work in the dataflow expression builder. To get it correctly, you can concatenate the parameter using + to get desired result.
'{"queries":[{"query":"'+$query+'"}],"serializerSettings":{"includeNulls":true}}'
Using the following content in expression builder also works (using concat() function).
concat('{"queries":[{"query":"',$query,'"}],"serializerSettings":{"includeNulls":true}}')
I'm creating a simple Rest Api with the basic layering Controller-Service-Repository.
I have the following questions:
Where should I check if the correct parameters are given?
How should I validate thiese parameters e.g throw Response error?
You could validate your parameters on the first middleware (or after the authorization middleware). For example, in an express application you could pass your request body into a joi validation scheme.
Depends on your business logic. You can either set default values for parameters not defined by user or throw error. For example, if a user has not given any username or password parameter, then you should throw an error. All errors should be handled by the last middleware and return a relevant status code (401, 402, etc) with an information message if needed.
I am very new to SoapUI, and need some help,
I want to test multiple SOAP requests - just kind of smoke test and save result in text file along with error message of failed response.
I have created testcase with all SOAP request and used invalid HTTP assertion to validate pass/fail one [as mentioned just smoke test] and wirting result in to txt file using tear down script.
I have created Custom properties for each SOAP request and using property transfer step fetched Error message & reporting entity.
Now my concern is, how to write those property values in txt file along with result.
I am using below mentioned teardown script to store result.
`import org.codehaus.groovy.scriptom.*
import org.codehaus.groovy.scriptom.tlb.office.excel.*
def testsuitename=testRunner.testCase.testSuite.name
def testcasename=testRunner.testCase.name
groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def results = testRunner.results
f = new File( "C:\\Users\\%user%\\Documents\\Downloads\\Smoke Test Result\\result.txt")
for( r in testRunner.results )
{
f.append(r.testStep.name + "," + r.status + "\r\n")
}`
Output is something like this:
step-1-name,FAILED
step-2-name,OK
step-3-name,OK
I am looking for output with error message
step-1-name,FAILED,Error message,Reporting Entity
step-2-name,OK,null,null
step-3-name,OK,null,null
I have already fetched Error message & entity using XPATH in properties.
I am validating an email address using zend_validate_email.
For example, for email address aa#aa it throws several error messages including very technical describing that DNS mismatch (:S).
I am trying to make it display only 1 message that I want it to (for example: "Please enter a valid email").
Is there any way of doing it elegantly, apart from creating a subclass and overriding the isValid method, clearing out the array of error messages?
Thanks!
$validator = new Zend_Validate_EmailAddress();
// sets the message for all error types
$validator->setMessage('Please enter a valid email');
// sets the message for the INVALID_SEGMENT error
$validator->setMessage('Something with the part after the # is wrong', Zend_Validate_EmailAddress::INVALID_SEGMENT);
For a full list of errors and message templates see the Zend_Validate_EmailAddress class