Cosmos DB throws The input content is invalid because the required properties - 'id; ' - are missing Error - azure-cosmosdb

I am trying to insert a JSon document into azure cosmos db, My Json document has and id column existing with string value. While inserting this JSONObject to Cosmos DB using CreateItem function but it throws error saying "The input content is invalid because the required properties - 'id; ' - are missing". Below is the code and sample JSONObject loading. Can some one help?
query = "select * from <ks>.<tn>";
Statement st = new SimpleStatement(query);
ResultSet rows = session.execute(st.setFetchSize(1000));
Iterator<Row> it = rows.iterator();
while (it.hasNext()) {
if (rows.getAvailableWithoutFetching() == 100 && !rows.isFullyFetched())
rows.fetchMoreResults();
}
Row row = it.next();
JSONObject jsonObject = new JSONObject(row.getString("[json]"));
jsonObject.put("id",jsonObject.get("doc_id"));
CosmosItemRequestOptions cosmosItemRequestOptions = new
CosmosItemRequestOptions();
CosmosItemResponse<JSONObject> item = container.createItem(jsonObject, new
PartitionKey((String) jsonObject.get("doc_id")), cosmosItemRequestOptions);
}
Sample Json doc:
{
"abc": null,
"year": 1996,
"name": "",
"num": null,
"anum": null,
"st": "mo",
"did": "1398",
"de": null,
"sq": null,
"dq": "",
"d":null,
"dpp": null,
"dif": null,
"dmf": null,
"dtc": null,
"id": "1398-48",
"day": null,
"dtc": null,
"drt": null,
"nr": null,
"daf": null,
"ds": null,
"da": null,
"andrf": null
}

Related

How can I get data from a stored procedure that contains a Cursor with another Cursor inside it

How can I get data from a stored procedure that contains a cursor with another cursor inside it in ASP.NET ?
When I try this code, I get the following error:
Unsupported Oracle data type RSET encountered
I need to fetch data from oracle and transfer it to a web service
Oracle 9i
This is the stored procedure and the code that I work on:
PROCEDURE P_GET_VST_CLAIMS_CLAIMSDTL ( P_PAGE_SIZE NUMBER, P_PAGE_NUMBER NUMBER, P_VST_ID NUMBER, P_PAT_ID NUMBER, P_REFCUR OUT SYS_REFCURSOR )
IS
/*
P_REFCUR_DATA STRUCTURE
----------------------------------------------------------------
VST_ID,
OL2CLAIMS_ID,
CLM_DATE,
MPTYPE_ID,
MP_TYPE_DESC_E,
MP_TYPE_DESC_A,
CLM_MP_ID,
PROVIDER_NAME_E,
PROVIDER_NAME_A,
MP_BRANCH_ID,
MP_PART_ID,
STATUS,
STATUS_DESCE,
STATUS_DESCA,
PAT_ID,
PAT_NAME_E,
PAT_NAME_A,
CLM_AMT,
CO_INS_TOT_AMT,
ATTACHS
CLAIMDTL (REFCUR)
ID NUMBER
VST_ID NUMBER
CLM_ID NUMBER
DTL_TYPE VARCHAR2
DTL_ID NUMBER
DESC_E VARCHAR2
DESC_A VARCHAR2
HCPC_ID NUMBER
MDSN_ID NUMBER
QTY NUMBER
UNIT_DESC_E VARCHAR2
UNIT_DESC_A VARCHAR2
TQ_ID NUMBER
TQ_DESC_E VARCHAR2
TQ_DESC_A VARCHAR2
REQUESTED_REPETITION NUMBER
CLM_AMT NUMBER
PRICE_LIST_AMT NUMBER
PRICE_LIST_REJ_AMT NUMBER
CO_INS_TOT_AMT NUMBER
CO_INS_DESERVED_AMT NUMBER
TPA_MP_SERVICE_AMT NUMBER
MP_DISC_AMT NUMBER
MP_NET_AMT NUMBER
*/
C# code:
[HttpPost]
[Obsolete]
public IHttpActionResult P_GET_VST_CLAIMS_CLAIMSDTL([FromBody] OracleParameters model)
{
IHttpActionResult httpActionResult;
try
{
string UsernameConfig = WebConfigurationManager.AppSettings["AppUsername"];
string PasswordConfig = WebConfigurationManager.AppSettings["AppPassword"];
if (model.AppUserName != UsernameConfig)
{
httpActionResult = this.Return_Response(false, 5, "Application Username Or Password not correct", null);
}
else if (model.AppPassword == PasswordConfig)
{
using (OracleConnection connection = new OracleConnection("Data Source= (DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = db1))); User Id=coreapps; Password=coreapps;"))
{
OracleDataAdapter da = new OracleDataAdapter();
OracleCommand cmd = new OracleCommand()
{
Connection = connection,
CommandText = "PKG_COREAPPS.P_GET_VST_CLAIMS_CLAIMSDTL",
CommandType = CommandType.StoredProcedure
};
cmd.Parameters.Add("P_PAGE_SIZE", OracleType.Number).Value = model.P_PAGE_SIZE;
cmd.Parameters.Add("P_PAGE_NUMBER", OracleType.Number).Value = model.P_PAGE_NUMBER;
cmd.Parameters.Add("P_VST_ID", OracleType.Number).Value = model.P_VST_ID;
cmd.Parameters.Add("P_PAT_ID", OracleType.Number).Value = model.P_PAT_ID;
cmd.Parameters.Add("P_REFCUR", OracleType.Cursor).Direction = ParameterDirection.Output;
connection.Open();
OracleDataAdapter da1 = new OracleDataAdapter(cmd);
DataSet ds = new DataSet();
da1.Fill(ds);
ClsLog.TextLog(ds.Tables[0].Rows[0][0].ToString());
connection.Close();
httpActionResult = this.Return_Response1(true, 1, "Success", ds);
}
}
else
{
httpActionResult = this.Return_Response(false, 5, "Application Username Or Password not correct", null);
}
}
catch (Exception exception)
{
Exception ex = exception;
ClsLog.OnError(ex);
httpActionResult = this.Return_Response(false, 3, ex.Message, null);
}
return httpActionResult;
}

Flask restx api model not showing model data

I have a model as follows:
class Menu(db.Model):
itemId = db.Column(db.Integer,primary_key=True)
name = db.Column(db.String(255),index=True)
price = db.Column(db.Numeric)
description = db.Column(db.String(255),index=True)
image = db.Column(db.LargeBinary)
restaurantId = db.Column(db.Integer, db.ForeignKey('restaurants.id'))
createdOn = db.Column(db.DateTime,server_default=db.func.now())
status = db.Column(db.Integer,server_default="1")
orders = db.relationship('Orders', backref='menu', lazy='dynamic')
def __repr__(self):
return '<Menu of restaurant id {}>'.format(self.restaurantId)
And I have the following api model corresponding to it:
menu_model = api.model('Menu',
{'itemId':fields.Integer(),
'name':fields.String(),
'price':fields.Float(),
'description':fields.String(),
'restaurantId':fields.Integer(),
'createdOn:':fields.DateTime(),
'status':fields.Integer()})
The problem is that even though the createdOn values are correctly generated on DB side, the response shows the createdOn field as null. What could be the reason?
"menu":
{
"itemId": 1,
"name": "Menu item",
"price": 30.0,
"description": "Menu item description",
"restaurantId": 1,
"createdOn:": null,
"status": 1
}
this will accept the desired output. The first parameter is a label, not part of the json
menus = api.model(
"menu_item",
{
'itemId':fields.Integer(),
'name':fields.String(),
'price':fields.Float(),
'description':fields.String(),
'restaurantId':fields.Integer(),
'createdOn:':fields.DateTime(),
'status':fields.Integer()
},
)
menu_model = api.model(
"Menu",
{
"menu": Nested(menus),
},
)

filtered_search api in freshworks CRM not returning custom attributes

I need data from freshworks CRM rest api and I am using /api/filtered_search/[entity] api to get data modified between 2 time periods. This query is returning correct data. But the result doesn't include all the attributes of a record as the result from view api /api/sales_accounts/view/[view_id]. What should I do to get all attributes of records that are modified between 2 time periods ?
Sample query:
curl -H "Authorization: Token token=XXXXXXX -X POST https://personal-XXXX.myfreshworks.com/crm/sales/api/filtered_search/sales_account?include=owner -d '{ "filter_rule" : [{"attribute" : "updated_at", "operator":"is_in_the_range", "value":["2021-02-10T10:00:00", "2021-02-10T15:00:00"]}] }'
Result:
{
"id": 70000227816,
"name": "Everstage Acc 1",
"last_contacted": null,
"last_contacted_mode": null,
"city": null,
"state": null,
"country": null,
"phone": "1234567890",
"open_deals_amount": "0.0",
"won_deals_amount": "0.0",
"avatar": null,
"created_at": "2021-02-08T22:46:03+05:30",
"updated_at": "2021-02-10T12:31:56+05:30",
"recent_note": null,
"last_contacted_via_sales_activity": null,
"last_contacted_sales_activity_mode": null,
"last_assigned_at": "2021-02-08T22:46:04+05:30",
"facebook": null,
"twitter": null,
"linkedin": null,
"owner_id": 70000012204
}
Expected Result:
{
"id": 70000227816,
"name": "Everstage Acc 1",
"address": "12, abc street, 1st cross, 2nd main",
"city": null,
"state": null,
"zipcode": null,
"country": null,
"number_of_employees": 11,
"annual_revenue": 12,
"website": null,
"owner_id": 70000012204,
"phone": "1234567890",
"open_deals_amount": "0.0",
"open_deals_count": 0,
"won_deals_amount": "0.0",
"won_deals_count": 0,
"last_contacted": null,
"last_contacted_mode": null,
"facebook": null,
"twitter": null,
"linkedin": null,
"links": {
"conversations": "/crm/sales/sales_accounts/70000227816/conversations/all?include=email_conversation_recipients%2Ctargetable%2Cphone_number%2Cphone_caller%2Cnote%2Cuser&per_page=3",
"document_associations": "/crm/sales/sales_accounts/70000227816/document_associations",
"notes": "/crm/sales/sales_accounts/70000227816/notes?include=creater",
"tasks": "/crm/sales/sales_accounts/70000227816/tasks?include=creater,owner,updater,targetable,users,task_type",
"appointments": "/crm/sales/sales_accounts/70000227816/appointments?include=creater,owner,updater,targetable,appointment_attendees"
},
"custom_field": {
"cf_customer_succses_email_id": "customer2#abc.com"
},
"created_at": "2021-02-08T22:46:03+05:30",
"updated_at": "2021-02-10T12:31:56+05:30",
"avatar": null,
"parent_sales_account_id": null,
"recent_note": null,
"last_contacted_via_sales_activity": null,
"last_contacted_sales_activity_mode": null,
"completed_sales_sequences": null,
"active_sales_sequences": null,
"last_assigned_at": "2021-02-08T22:46:04+05:30",
"tags": [],
"is_deleted": false,
"team_user_ids": null
}
You can get the list of Sales Account using /api/sales_accounts/view/[view_id] with sort and sort type as updated_at and desc to get the latest updated records. The filtered search API /api/filtered_search/[entity] gives only basic details. Try https://developers.freshsales.io/api/#view_account API for complete attributes per record

Is it possible to update existing Dynamo DB table from Terraform

I am trying to create a terraform module with the help of which I can make an entry to existing Dynamo DB table.
I have got this code which create dynamo DB table
resource "aws_dynamodb_table" "basic-dynamodb-table" {
name = "GameScores"
billing_mode = "PROVISIONED"
read_capacity = 20
write_capacity = 20
hash_key = "UserId"
range_key = "GameTitle"
attribute {
name = "UserId"
type = "S"
}
attribute {
name = "GameTitle"
type = "S"
}
attribute {
name = "TopScore"
type = "N"
}
ttl {
attribute_name = "TimeToExist"
enabled = false
}
global_secondary_index {
name = "GameTitleIndex"
hash_key = "GameTitle"
range_key = "TopScore"
write_capacity = 10
read_capacity = 10
projection_type = "INCLUDE"
non_key_attributes = ["UserId"]
}
tags = {
Name = "dynamodb-table-1"
Environment = "production"
}
}
Is there any way I can make changes in existing dynamo db table.
For adding entries to a table you can take a look at the aws_dynamodb_table_item resource. Here is an example that you can use to add an entry to your table:
resource "aws_dynamodb_table_item" "item1" {
table_name = aws_dynamodb_table.basic-dynamodb-table.name
hash_key = aws_dynamodb_table.basic-dynamodb-table.hash_key
range_key = aws_dynamodb_table.basic-dynamodb-table.range_key
item = <<ITEM
{
"UserId": {"S": "user"},
"GameTitle": {"S": "gamex"},
"TopScore": {"N": "42"}
}
ITEM
}

System.Data.SQLite transaction lock whole database

I'm trying to insert into 2 different tables from different transactions. Unfortunally I'm getting "database locked" exeption onto cn2.Execute...
var cb = new System.Data.SQLite.SQLiteConnectionStringBuilder
{
BinaryGUID = true,
DataSource = string.Format("file:SqliteTest-{0:N}.db", Guid.NewGuid()),
FailIfMissing = false,
JournalMode = System.Data.SQLite.SQLiteJournalModeEnum.Wal,
LegacyFormat = false,
Pooling = true,
SyncMode = System.Data.SQLite.SynchronizationModes.Normal,
DefaultIsolationLevel = System.Data.IsolationLevel.ReadCommitted
};
using (var cn1 = new System.Data.SQLite.SQLiteConnection(cb.ToString()))
{
cn1.Open();
cn1.Execute("create table t_1(uuid BLOB not null primary key, ts INTEGER not null);");
cn1.Execute("create table t_2(uuid BLOB not null primary key, ts INTEGER not null);");
using (var cn2 = (System.Data.SQLite.SQLiteConnection)cn1.Clone())
{
using (var tr1 = cn1.BeginTransaction(System.Data.IsolationLevel.ReadCommitted))
using (var tr2 = cn2.BeginTransaction(System.Data.IsolationLevel.ReadCommitted))
{
cn1.Execute("insert into t_1(uuid,ts) values(#uuid, #ts);",
new { uuid = Guid.NewGuid(), ts = DateTime.UtcNow.Ticks }, tr1);
cn2.Execute("insert into t_2(uuid,ts) values(#uuid, #ts);",
new { uuid = Guid.NewGuid(), ts = DateTime.UtcNow.Ticks }, tr2);
}
}
}

Resources