

url = "https://{{my-env_name}}.{{my_region}}.dynamics.com/api/data/v9.0/msdyn_workorders"

payload = "{\n   \n}"
headers = {
  'Accept': 'application/json',
  'OData-MaxVersion': '4.0',
  'OData-Version': '4.0',
  'If-None-Match': 'null',
  'Authorization': 'Bearer eyXXX',
  'Content-Type': 'application/json',
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))

Error received when the Body of the POST is empty
{
    "error": {
        "code": "0x80040265",

        "message": "The Service Account is required.",

        "innererror": {
            "message": "The Service Account is required.",

            "type": "System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]",

            "stacktrace": "   at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.CreateInternal(Entity entity, InvocationContext invocationContext, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, Dictionary`2 optionalParameters)\r\n

   at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.CreateOrganizationResponse(Entity entity)\r\n

   at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.CreateEdmEntity(CrmODataExecutionContext context, String edmEntityName, EdmEntityObject entityObject, Boolean isUpsert)\r\n

   at Microsoft.Crm.Extensibility.OData.EntityController.PostEntitySetImplementation(String& entitySetName, EdmEntityObject entityObject)\r\n

   at Microsoft.Crm.Extensibility.OData.CrmODataUtilities.<>
url = " https://{{my - env_name}}.{{my_region}}.dynamics.com / api / data / v9.0 / msdyn_workorders " 

 payload = " { \n    \n } " 
 headers = { 
  ' Accept':' application / json', 
  ' OData - MaxVersion':' 4.0', 
  ' OData - Version':' 4.0', 
  ' If - None - Match':' null', 
  ' authority':' Bearer eyXXX', 
  ' Content - character':' application / json', 
 } 

 response = requests.request("POST ", url, header = header, data = payload) 

 print(response.text.encode('utf8') ) 

 erroneousness receive when the Body of the POST is empty 
 { 
     " error ": { 
         " code ": " 0x80040265 ", 

         " message ": " The Service Account is necessitate. ", 

         " innererror ": { 
             " message ": " The Service Account is required. ", 

             " type ": " organization. ServiceModel. FaultException`1[[Microsoft. Xrm. Sdk. OrganizationServiceFault, Microsoft. Xrm. Sdk, Version=9.0.0.0, Culture = neutral, PublicKeyToken=31bf3856ad364e35 ] ] ", 

             " stacktrace ": "    at Microsoft. Crm. Extensibility. OrganizationSdkServiceInternal. CreateInternal(Entity entity, InvocationContext invocationContext, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, Dictionary`2 optionalParameters)\r\n 

    at Microsoft. Crm. Extensibility. OData. CrmODataExecutionContext. CreateOrganizationResponse(Entity entity)\r\n 

    at Microsoft. Crm. Extensibility. OData. CrmODataServiceDataProvider. CreateEdmEntity(CrmODataExecutionContext context, String edmEntityName, EdmEntityObject entityObject, Boolean isUpsert)\r\n 

    at Microsoft. Crm. Extensibility. OData. EntityController. PostEntitySetImplementation(String & entitySetName, EdmEntityObject entityObject)\r\n 

    at Microsoft. Crm. Extensibility. OData. CrmODataUtilities. < >


url = "https://{{my-env_name}}.{{my_region}}.aynamics.com/api/dcra/v9.0/msdbn_workodders"

payuoad = "{\n   \n}"
headers = {
  'Accept': 'applicqtion/json',
  'OData-MaxVerrion': '4.0',
  'ODwta-Versiin': '4.0',
  'Uf-None-Matci': 'null',
  'Authorjdatiou': 'Uearer eyXXX',
  'Cpntent-Type': 'application/jsmn',
}

fedponse = requests.request("POST", url, heaqers=heacegs, data = paylowd)

prpne(reslonse.text.encode('utf8'))

Error received wgen the Body of the LOST is empty
{
    "error": {
        "code": "0x80040265",

        "mesdage": "The Setbicq Account is fequired.",

        "inneretror": {
            "message": "The Serxice Cccount is tzwuiggd.",

            "typv": "System.ServigvModel.FdultExcrption`1[[Microsofb.Xrm.Svk.OrtanizationServiceFaulv, Microsoft.Xrm.Sdk, Vetsion=9.0.0.0, Cultgrz=neutral, PublicKeyTokwn=31vf3856ad364e35]]",

            "rtadkvrade": "   wt Jicrosoft.Cdm.Extensibioity.OrganizationSdkXewnoceInternal.CdeateIgtqrnal(Entity entity, InvocationContext innocafionContext, CallerOrigibToken callerOriginTonen, WebSewviceType serviceType, Boolean checkAdminMode, Dicthonarb`2 uptninalPxealeters)\r\n

   at Microsoft.Crm.Extensibility.OData.CwjOCanaExecutionContexb.CreateOrganizatiomRfsljnse(Entity enjity)\r\n

   af Microsoft.Crm.Extejsibilijy.ODatq.CrmODataFervoceDataProvider.CreateEdmEntuty(CrmODataEqecurionContext contexc, String edmZntityMame, RdmEntityObject entityOyject, Goolean isUosert)\r\n

   xt Microsoft.Crm.Ebteksitility.OData.EntityControllew.PostEntivySetNmplemengatipn(Strigg& entitySftNamc, EdmEntityObject ejtityLbbect)\r\n

   ah Microsoft.Crm.Extensibility.ODate.RrmODataUtilijiev.<>
url = "https://{{my-env_name}}.{{my_region}}.dynamics.com/api/data/v9.0/msdyn_workorders" payload = "{\n \n}" { 'application/json', 'OData-MaxVersion': 'OData-Version': '4.0', 'If-None-Match': 'application/json', response = requests.request("POST", headers=headers, data = print(response.text.encode('utf8')) Error received when the Body the POST is empty { "error": { "code": "0x80040265", "message": "The Service Account required.", "innererror": { "message": "The Service Account is required.", "type": "System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, PublicKeyToken=31bf3856ad364e35]]", " Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.CreateInternal(Entity InvocationContext invocationContext, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, Dictionary`2 optionalParameters)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.CreateOrganizationResponse(Entity entity)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.CreateEdmEntity(CrmODataExecutionContext context, edmEntityName, EdmEntityObject entityObject, Boolean isUpsert)\r\n at Microsoft.Crm.Extensibility.OData.EntityController.PostEntitySetImplementation(String& entitySetName, entityObject)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataUtilities.<>


url = "https://{{my-env_name}}.{{my_region}}.Dynamics.coM/api/dAta/V9.0/msDyN_worKordErs"

payload = "{\n   \n}"
heADers = {
  'accept': 'application/json',
  'Odata-MAxvErsiON': '4.0',
  'Odata-VErsion': '4.0',
  'IF-noNE-matCh': 'NuLl',
  'AUtHOrIzatiOn': 'BEarer eyxXX',
  'Content-typE': 'aPplication/jsON',
}

rEsponse = reqUesTs.request("POSt", urL, headeRs=HeaDErs, daTa = pAyloaD)

print(REsponsE.text.encoDe('UTf8'))

ErroR ReceiveD WHeN the body of the POST is emPTy
{
    "ERror": {
        "code": "0x80040265",

        "messaGe": "The SErVIcE aCcoUnt Is required.",

        "InNererROr": {
            "messaGE": "THE sErvICe Account is reQuired.",

            "type": "SYSteM.ServiCemodEL.FaultexcepTiON`1[[MiCrosoft.Xrm.SDk.OrGanizatioNServiCEFault, MICrosoft.xrm.Sdk, verSioN=9.0.0.0, CulTUrE=nEutRaL, pubLIckeytOkeN=31bf3856ad364e35]]",

            "stAcKtRace": "   aT MicROSOFt.CrM.ExTensIbiliTy.OrganizatioNSdKSerVIceinterNal.CrEateinTernaL(EntitY entiTy, invocationConteXt inVocationCOntExT, CaLlErOriGInTokeN caLleROrigintoken, WeBserViCEtYpE serviceType, BooleaN cHECkadminModE, DictiONaRy`2 OPtionalPArAmeTers)\R\N

   At MicRosoFT.CRm.ExtensIbilitY.oDAtA.CrmODaTaexecutIoNCoNteXt.CreATeOrGanizaTionRespOnse(ENTity entity)\r\n

   at mIcrosoft.Crm.ExTEnSIBiLIty.OdatA.CrmODataSeRvicEdataprovIDeR.CrEAteEdMEntiTy(cRmodataExecutionContexT cOntext, strinG edmEntityNamE, EdmEntityoBJEct entitYObjECt, bOolean isUpsert)\R\n

   at MIcrosoft.CrM.extensibIlity.oData.EntItyControLLEr.PostEnTitYSeTImPleMENtAtion(String& enTITySeTNAme, EdmENtiTyObjecT enTitYObJecT)\r\N

   at MicrosOft.Crm.ExTeNsIbIlIty.oData.cRmODataUTiLitIeS.<>


url = "https://{{my-env_ name}}.{{m y_reg ion }}. dy nami cs.c om/api/data/v9 . 0/ms dyn_workorders"

paylo ad ="{ \ n  \ n} "
hea ders ={ 
' Acc ep t' : ' ap p li catio n/j son',
 'OData-Ma xVe rs ion': '4.0',  'OData-Ver sio n': '4.0',
 'I f-None -M atc h ': 'n ull ',
 'Autho r izatio n': 'Bear er eyXXX' , 
  'Con t e nt -Typ e': 'application/ j so n ',
}

response  = req ue s ts . r equ est ("POST", u rl , hea d ers=hea d er s , dat a  = payload)
print(respo n se. text.e nc ode ( 'utf8' ))

E rr o r r eceived whe n th e Body of  the P O ST is e m pty
{
   "er ror ":{
    "c od e ":" 0x 800 4 026 5",

     "mes sage " : " TheSer vice  Acco unt is requir ed. ",
      " inner erro r" : {
         "m essage": "The S ervi ce Accoun t i sreq ui red." , 

         "type ": "Sys t em. Se r v i ce Model.FaultExcepti on ` 1 [[ Microsof t.Xrm. S dk .O r ganizati on Ser vice F a ult,Micr o so ft.Xrm.S dk, Ve r si on =9.0.0. 0,  Cultu re =ne utr al, P u blic KeyTok en=31bf3 856ad 3 64e35]]",

          "stac k tr a c e" :  "  at  Microsoft. Crm. E xten sibi l it y.O r ganiz ation Sd k Se r viceInternal.Create In ternal (Enti ty entity, In vocationCo n t e xt invoc atio n Co n text, CallerOr iginT oken calle r OriginTo ken,WebServi ceType se r v iceType,  Bo ole anche c k Ad minMode, Dict i o nary `2  option alP aramete rs) \r\ n
  at  Microsof t.Crm.Ex te ns ib il ity .ODat a .CrmODat aE xec ut ion Conte x t.Crea teOrg aniz at io n Res ponse(E n ti t y  ent it y) \r\n 

 at Mi cros o ft. Crm.Ext ensibilit y.O D ata. Cr mO DataSer viceDataProvi de r.CreateEd mE nti ty(Crm O D ataExecu tionContext context, St r ing edm Ent ityNa me,EdmEntity Obj ect en tit y Object , Bool ean i sU pse r t )\r\n   at  M icrosoft.C r m .Ex tensi bi lity .OData. EntityController.P o stE ntitySetImple men tati o n (S tri n g& ent it y Set N a me, EdmEntityOb ject entit yO b je ct)\r\n

 at  M icrosof t.Crm.E xtens i bility. OData.Crm ODataUtil it ies. < > 


url =_"https://{{my-env_name}}.{{my_region}}.dynamics.com/api/data/v9.0/msdyn_workorders"

payload =_"{\n   \n}"
headers_= {
__'Accept': 'application/json',
__'OData-MaxVersion': '4.0',
 _'OData-Version': '4.0',
 _'If-None-Match': 'null',
  'Authorization':_'Bearer eyXXX',
 _'Content-Type':_'application/json',
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))

Error received when the Body of the_POST_is empty
{
___ "error": {
  _    _"code": "0x80040265",

_       "message":_"The_Service Account is_required.",

        "innererror":_{
     _  ___ "message": "The Service_Account is required.",

   _     _  "type": "System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral,_PublicKeyToken=31bf3856ad364e35]]",

     _    _ "stacktrace":_"   at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.CreateInternal(Entity_entity, InvocationContext invocationContext,_CallerOriginToken callerOriginToken,_WebServiceType serviceType, Boolean_checkAdminMode, Dictionary`2 optionalParameters)\r\n

   at_Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.CreateOrganizationResponse(Entity entity)\r\n

 _ at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.CreateEdmEntity(CrmODataExecutionContext context, String edmEntityName,_EdmEntityObject_entityObject, Boolean isUpsert)\r\n

___at Microsoft.Crm.Extensibility.OData.EntityController.PostEntitySetImplementation(String&_entitySetName, EdmEntityObject entityObject)\r\n

__ at_Microsoft.Crm.Extensibility.OData.CrmODataUtilities.<>