I have an issue that i was not able to solve yet & it is blocking my work with MongoDB.
I use MongoDBLibrary in robot framework and I'm able to query the mongoDB server BUT
the issue is that i get the response as invalid JSON.
example for the invalid output:
[{'_id': ObjectId('5f9ecf8ca9bec554567d'), 'policy_name': 'test'}, {'_id': ObjectId('6090fead53bc363856788'), 'policy_name': 'automation'}, {'_id': ObjectId('619cf036761c281e366767327'), 'policy_name': 'Without Module'}, {'_id': ObjectId('619cf729ea016d1e33364543'), 'policy_name': 'With module'}]
how can i get / convert the output to a valid json in robot framework.
i tried many solution but could not find the right one.
what does this error mean: "NameError: name 'ObjectId' is not defined nor importable as module"?
please assist
Related
I had the following code, which was running well with EF Core 2.1:
.FirstOrDefault(a => (a.Name.Equals(b, StringComparison.InvariantCultureIgnoreCase).
(Ok, running well means I got the right results even if it was being evaluated in the client side and I didn't know it).
I updagred to EF Core 3.0 and I didn't get any error, but this code was not giving the expected results.
I saw here a solution. I tried a.Name.ToLower() == b.ToLower() but then I got the the error:
Error CA1304 The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'MyFunction(string, string)' with a call to 'string.ToLower(CultureInfo)'
If I use a ToLower(CultureInfo.InvariantCulture) I get the message:
Error CA1308 In method 'MyFunction', replace the call to 'ToLower' with 'ToUpperInvariant'.
If I use ToUpperInvariant(), then I get the error (I'm already aware of the LINQ breaking changes in EF Core 3.0):
The LINQ expression (... all the expression...) could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync().
So, I am the starting point.
Is there a way to both comply with CA1304 and run the query in the DB and not in the client side?
The solution, as PanagiotisKanavos commented, was to simply use a.Name == b. Easy and it works!
I have used an ARM Template to deploy a Microsoft.Maps/account resource to Azure.
That was successful:
Resource Microsoft.Maps/accounts 'nzmoebasedemo0000bt' provisioning status is succeeded
I'd like to retrieve the Primary key generated, within the ARM template, in order to persist it to a KeyVault.
I looked in https://resource.azure.com but the Maps/account provider was not listed, so could find no hint as to what property to read.
I tried:
[listKeys(resourceId('Microsoft.Maps/account', 'parameters('keyVaultVaultSecretMapsAccountResourceName')'), providers('Microsoft.Maps', 'account').apiVersions[0]).keys[0].value]"
Abd got back:
#{parameters=; status=Trial run failed. ; outputs=; provisionStateSucceeded=False; deploymentOutput=; errorCode=InvalidTemplate; errorMessage=Deployment template validation failed: 'The template resource 'azure.arm.base.keyVault.vault.secret' at line '168' and column '9' is not valid: Unable to evaluate template language function 'providers': function requires the second argument to be a multi-segmented resource type excluding the resource provider namespace. Invalid function argument 'account'. Please see https://aka.ms/arm-template-expressions/#providers for usage details.. Please see https://aka.ms/arm-template-expressions for usage details.'.}
Which in this case...seems incorrect.
What am I not seeing/getting?
Thanks!
Edit:
As per suggestion given, the following did pass a test run.
"[listKeys(resourceId('Microsoft.Maps/account', parameters('keyVaultVaultSecretMapsAccountResourceName')), '2018-05-01').keys[0].value]"
But when actually run, got the following:
1:02:35 AM - Resource Microsoft.Maps/account 'nzmoebasedemo0000bt' failed with message '{
"error": {
"code": "InvalidResourceType",
"message": "The resource type could not be found in the namespace 'Microsoft.Maps' for api version '2018-05-01'."
}
}'
Edit again:
As per guidance given in the comments, the following works! (after correcting api version, spelling mistake, and using 'primaryKey' property:
"[listKeys(resourceId('Microsoft.Maps/accounts', parameters('keyVaultVaultSecretMapsAccountsResourceName')), '2018-05-01').primaryKey]"
So the problem was due to a typo, the provider\resource is Microsoft.Maps/accounts
I need to be able to create a multipart mail message including images.
I found this suggestion Sending HTML code in a mail using Poco library but when I try this with VS2015/Windows/C++
Poco::Net::MediaType mediaType("multipart", "related");
I get
Error C2440 'initializing': cannot convert from 'initializer list' to 'int' AdvancedEmailer
Error C2079 'mediaType' uses undefined class 'Poco::Net::MediaType' AdvancedEmailer
I've looked at https://pocoproject.org/docs/Poco.Net.MailMessage.html but I can't figure out what's wrong
whats the correct usage for Poco::Net::MediaType
I connected to oracle database and fetched some of the columns from the table.
It gave one of the column as cx_Oracle.OBJECT with type <cx_Oracle.ObjectType SYS.XMLTYPE>.
I need to read the XML Data in this and validate.
I have idea that XML Library is there in robot framework, to parse the Object, it is not accepting cx_Oracle.OBJECT, how to read cx_Oracle.OBJECT of type <cx_Oracle.ObjectType SYS.XMLTYPE>.
My Robot Framework Testcase is as below:
Query From CB_ADDRESS_XML
Connect To Database Using Custom Params cx_Oracle '${Username}/${Password}#${Host}:${Port}/${DatabaseName}'
${result}= Query select address_x from cb_address_xml where ACCOUNT_LINK_CODE_N='21818'
Log ${result[0][0]}
Disconnect From Database
Output came as :
INFO : ${result} = [(<cx_Oracle.OBJECT object at 0x032AE700>,), (<cx_Oracle.OBJECT object at 0x032AE720>,), (<cx_Oracle.OBJECT object at 0x032AE740>,)]
INFO : <cx_Oracle.OBJECT object at 0x032AE700>
<cx_Oracle.OBJECT object at 0x032AE700> is a xml object, i want to read this and validate the values in xml.
Thanks
Sarada
This could be implemented as a python keyword and used in Robot framework.
When you implement execute query in python call as below:
cursor.execute("select XMLType.GetClobVal(address_x) from cb_address_xml where ACCOUNT_LINK_CODE_N='21818'")
Once you receive the result it will be of type cx_Oracle.LOB, so you can use the below to read its contents:
result[column_number].read()
This will return XML data which you are looking for.
NOTE: This should be done before you close the DB connection.
Good Luck!
I'm not able to create view in oracle through a select query that uses PIVOT function
It gives the following error.I'm not able to understand what's the problem.Please help
Refer to the image at the following address for error snapshot.The error can be seen at
following address"https://www.dropbox.com/s/sq98mvfourobo7w/Error.PNG"
I can't see your item from work (dropbox is blocked), but I ran across this issue using the create view wizard in sql developer: it would throw out an error for an unexpected token ! PIVOT.
The workaround was to simply use CREATE OR REPLACE FORCE VIEW from the SQL worksheet and avoid the wizard.