azure cosmosdb - DocumentDB Rest API - create document needs id for new documents -


i'm trying use documentdb rest api create new document , autogenerate id me.

the create document documentation says id required property of body, node.js sdk , azure portal document explorer both generate id's when no id provided in input.

here's response server:

{ code: 'badrequest',   message: 'message: {"errors":["the input content invalid because required properties - \'id; \' - missing","the request payload invalid. ensure provide valid request pa yload."]}\r\nactivityid: 6b718b3d-01bc-403f-82e6-266254aad952, request uri: /apps/4c8d65d7-216b-46b4-abb7-52c1a0c7123f/services/0e58e0c6-ff02-4523-a94b-204abd0d2179/partitions/6bf7ec3e-d850 -440e-bbcb-50d949389f3e/replicas/131469737377192972p' } 

i noticed documentdb node.js sdk generates own id's, not handled database.

here code use generate unique id's, packaged independent use:

function generateguidid () {   var id = "";    (var = 0; < 8; i++) {       id += gethexadigit();   }    id += "-";    (var = 0; < 4; i++) {       id += gethexadigit();   }    id += "-";    (var = 0; < 4; i++) {       id += gethexadigit();   }    id += "-";    (var = 0; < 4; i++) {       id += gethexadigit();   }    id += "-";    (var = 0; < 12; i++) {       id += gethexadigit();   }    return id;  }  function gethexadigit () {   return math.floor(math.random() * 16).tostring(16); } 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -