I want to create an Incident in Service Management Automation(Microfocus - SMAX) using API.
I use activity HTTP Request. My properties are as follow:
Accepted Format: JSON
Request Method : POST
Request URL: “https://smax.mycompany.com/rest/9966332211/ems/bulk”
Cookies = LWSSO_COOKIE_KEY=Token
Body:
{
‘entities’: [
{
‘entity_type’: ‘Incident’,
‘properties’: {
‘ContactPerson’: ‘’,
‘ImpactScope’: ‘Enterprise’,
‘IncidentToCompany’: ‘14728’,
‘Urgency’: ‘TotalLossOfService’,
‘DisplayLabel’: ‘Non reception du mail de volumetrie d’appel’,
‘CurrentAssignment’: ‘ServiceDesk’,
‘ServiceDeskGroup’: ‘14546’,
‘ExpertGroup’: ‘14533’,
‘RegisteredForActualService’: ‘15393’,
‘Description’: ‘This is a test Incident. Please ignore it.’
}
}
],
‘operation’: ‘CREATE’
}
I Get the following error as reposnone:
“errorDetails”: {
“httpStatus”: 500,
“message”: “Failed to evaluate DSL expression ${current_update.RegisteredForActualService.IsChanged && entity.RegisteredForActualService.SupportLevel1Group != null && entity.ServiceDeskGroup == null}”,
“developer_message”: “”,
“message_key”: “failed_to_evaluate_dsl_expression”,
“message_rb”: “locale/workflow_errors”,
“message_arguments”: [
“${current_update.RegisteredForActualService.IsChanged && entity.RegisteredForActualService.SupportLevel1Group != null && entity.ServiceDeskGroup == null}”
],
“exceptionType”: “WorkflowException”
}
Do you know what might cause the error?
Kind regards
Related
I am setting up an E2E test and chaining my request/responses. I am defining variables from each response and using them in the next call.
Its working up to a point, and then a problem surfaces when defining off the 2nd response.
If I def operationId, operationSubject, or operationStatus (e.g response.operationId), it works.
If I store anything from the results (e.g response.results.0.personId) it throws this error
Expected ; but found .0
response.results.0.personId
My response:
{
"operationId": "922459ecxxxxx",
"operationSubject": "BATCH_ENROLLMENT",
"operationStatus": "PROCESSED",
"results": {
"0": {
"personId": "367a73b5xxxx",
"status": "PRE_AUTH",
"email": "mquinter+TEST.69387488#email.com",
"loanNumber": null
},
"1": {
"personId": "56f060fd-e34xxxxxx",
"status": "PRE_AUTH",
"email": "mquintxxxx#email.com",
"loanNumber": null
}
}
}
That's not how to access data in JSON. See this similar question: https://stackoverflow.com/a/71847841/143475
Maybe you meant to do this:
* def foo = response.results[0].personId
https://stackoverflow.com/users/143475/peter-thomas
I see the issue - It wasn't finding the response because I wasn't giving it enough time before the next call.
I put a sleep in there and its working as expected.
Thanks
This question already has an answer here:
Optional field in JSON response
(1 answer)
Closed 1 year ago.
I'm starting to use Karate DSL for API testing. I've used before to do some basic tests.
I'm kind of mixing a dynamic data driven test, so I've read the documentacion and usages for this. I'm using the standalone jar file. Now, the problem is that I'm trying to use a json file as shown below:
[
{
"name": null,
"type": "informational",
"description": "Poseidon was one of the Twelve Olympians in ancient Greek religion and myth, god of the sea, storms.",
"tags": null,
"myAuth": null
},
{
"name": "RegressionTestKarate-dsfdgfdgdfsgfdgsfdgfdsgfdsgsdfg",
"type": "transactional",
"description": null,
"tags": ["regression", "poseidon", "suite", "test"],
"myAuth": null
}
]
And in my *.feature, I'm using the data to send a request like this:
* def myJson = { name: "##(name)", type: '##(type)', description: '##(description)', tags: '##(tags)' }
Given url poseidonHostUrl
And path "v1/projects"
And request myJson
When method post
Then assert responseStatus == 400 || responseStatus == 401 || responseStatus == 403
So, when I run my script, the replacement for the tags array when is not null is not as expected. It literally takes the following value: [...] "tags": "##(tags)".
Thanks!
As the above example shows your tags data is an array or null so you should try this as
* def myJson = { name: '##(name)', type: '##(type)', description: '##(description)', tags: '##[] #string' }
Given url poseidonHostUrl
And path "v1/projects"
And request myJson
When method post
Then assert responseStatus == 400 || responseStatus == 401 || responseStatus == 403
I have an API which has response as below:
"data": {
"catalog_list_items": [
{
"catalog_list_items": [
{
"catalog_list_items": [
{
"title": "L13",
"content_id": "58a85146b0000ec",
"sequence_no": 1,
"language": "hindi",
"genres": [
"xxxx"
]
I would like to create a test in postman to verify that the language key has value as 'hindi'. I am writing below test in Postman which always fails. Cannot find the reason.
var jsonData = JSON.parse(responseBody);
tests["Language is hindi"] = jsonData.data.catalog_list_items[3].language === "hindi";
However, when I use the similar structure to test sequence_no, it works fine
var jsonData = JSON.parse(responseBody);
tests["Sequence No is 1"]= jsonData.data.catalog_list_items[3].sequence_no === 1;
Can anyone shed a light for me?
I could see 3 level nested arrays in your response body.
So I don't know how are you getting your value through this expression:
jsonData.data.catalog_list_items[3].language
The correct expression to get the 'language' key from above response should be:
jsonData.data.catalog_list_items[0].catalog_list_items[0].catalog_list_items[0].language
I was trying to retrieve replica volume id using filter & softlayer services, but filter does not work.
objectFilterstorage = {"iscsiNetworkStorage": {"username": {"operation": storage_name}}}
client [Softlayer_Account].getIscsiNetworkStorage(filter=objectFilterstorage)
Here, I need help to get the object filter.
Please, try the following using SoftLayer_Account::getNetworkStorage:
https://[username]:[apikey]#api.softlayer.com/rest/v3/SoftLayer_Account/getNetworkStorage?objectMask=mask[id,username,replicationPartners[id,username]]&objectFilter={ "networkStorage": { "replicationPartners": { "username": { "operation": "MYUSERNAME_REP_1" } } } }
Method:GET
Question about real-time notification..
Post: https://xxxiot.cumulocity.com/cep/realtime
Body:
[
{
"channel": "/meta/handshake",
"version": "1.0",
"mininumVersion": "1.0beta",
"supportedConnectionTypes": ["long-polling","callback-polling"],
"advice":{"timeout":120000,"interval":30000}
}
]
My Response:
[
{
"minimumVersion": "1.0",
"supportedConnectionTypes": [
"smartrest-long-polling",
"long-polling"
],
"successful": true,
"channel": "/meta/handshake",
"ext": {
"ack": true
},
"clientId": "5o0ghvle7yy4ix41on423v6k3j87",
"version": "1.0"
}
]
After received the clientId.. I have run the following command:
Post: https://xxxiot.cumulocity.com/cep/realtime
Body:
[
{
"channel": "/meta/subscribe",
"clientId": "5o0ghvle7yy4ix41on423v6k3j87",
"subscription": "/alarms/overHeatAlarms"
}
]
Response:
[
{
"error": "403:denied_by_security_policy:create_denied",
"subscription": "/alarms/overHeatAlarms",
"successful": false,
"channel": "/meta/subscribe"
}
]
Where is the problem? I'm trying to subcribing to "overheatAlarms"!
It may be that it does not exist? Can I read the existing information?
Thanks,
Alim
Yes, your suspicion is correct. There are basically two options for you:
Subscribe to all alarms or alarms from a particular device: Use "/cep/realtime" and channel "/alarms/* resp. channel "/alarms/[device ID]".
Create a processing rule that filters out overheat alarms and subscribe to that rule: Use "/cep/notifications" and channel "/[module name]/[statement name]".
The module name is what you enter as name when you click "New module". The statement name is what you add to the statement, e.g.
#Name('overHeatAlarms')
select * from AlarmsCreated where [your condition for overheat alarms]
(If you don't put a name there, they will be name statement_1, statement_2, ....)
To get notifications from Java, have a look at an example of getting notifications for changes in devices. In the subscribe() method, you pass "*" or the device ID. To get the notification, pass an implementation of SubscriptionListener, in particular the onNotification method. You can modify "channelPrefix" to "/alarms/" or "/measurements/" to get other notifications.
Thanks, André.
I've tested following Code Snippet.. it works, but it is not the best solution :-)
MeasurementApi measurementApi = getMeasurementApi();
MeasurementFilter measurementFilter = new MeasurementFilter();
while (true) {
Calendar cal = Calendar.getInstance();
Date toDate = cal.getTime();
cal.add(Calendar.SECOND, -25);
Date fromDate = cal.getTime();
measurementFilter.byDate(fromDate, toDate);
measurementFilter.byFragmentType(TemperatureMeasurement.class);
measurementFilter.bySource(new GId(DEVICE_SIMULATOR));
MeasurementCollection mc = measurementApi
.getMeasurementsByFilter(measurementFilter);
MeasurementCollectionRepresentation measurements = mc.get();
for (; measurements != null; measurements = mc
.getNextPage(measurements)) {
for (MeasurementRepresentation measurement : measurements
.getMeasurements()) {
TemperatureMeasurement temperatureSensor = measurement
.get(TemperatureMeasurement.class);
System.out.println(measurement.getSource().getId() + " "
+ measurement.getTime()+ " " + temperatureSensor.getTemperature() );
}
}
}