ReadyAPI + CosmosDB connection
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ReadyAPI + CosmosDB connection
Hey Team,
I am trying to connect to Cosmos DB using the connection string but I am unable to connect to the collection available in the DB. Please find the script below. Please suggest how can I connect and read the data from the Cosmos DB collection.
import com.gmongo.GMongoClient
import com.mongodb.MongoCredential
import com.mongodb.ServerAddress
import com.mongodb.BasicDBObject
import com.gmongo.GMongo
def mongo = new GMongo('Sample Connection string');
def db = mongo.getDB('prs');
log.info("DB connected")
BasicDBObject query = new BasicDBObject("policy_number","12345")
def collection = db.getCollection('cccVacPolicy')
log.info("connect with PRS DB")
def myDoc = collection.findAll();
log.info myDoc.toString();
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think i have a CosmosDB ReadyAPI project saved somewhere. I'll try and dig it out, it might help.
Cheers,
Rich
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey @mayank451589
digging through my old hard drive now for it,
cheers,
Rich
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey @mayank451589
I found it - this isn't one of my projects - I think I found this on the web somewhere and saved it cos I thought - "I might have to test a CosmosDB endpoint one day"
I'm attaching the whole project - you'll have to edit the custom project level properties for your instance - but I think this will allow you to connect. the first testcase appears to have all the different REST requests to call all the different info you'd want - a Collection, All Collections, documents, etc.
Have a look and see if it helps,
Cheers,
Rich
