Acumatica Purchase Receipt Update Error: Sequence Contains No Matching Elements - acumatica

(All of the below is me directly sending requests to Acumatica via Postman)
Before attaching files to purchase receipts, I am able to update any purchase receipt as I wish. After attaching files to purchase receipts in Acumatica, I seem to be unable to update the purchase receipt after that and begin receiving the "Sequence Contains No Matching Elements" error. Does attaching files to purchase receipts change something that I am not aware of? Thank you in advance for any help!
Here is an example purchase receipt that I am attempting to update after attaching a small sample .txt file to the receipt
Here is a sample PUT request body sent to Acumatica to update receipt quantity to 33 (confirmed to be working if no files were attached, does not work after file attachment):
{
"id": "d5c53b1c-0b06-ed11-8312-0a72f5e849b2",
"rowNumber": 1,
"note": {
"value": ""
},
"BaseCurrencyID": {
"value": "CAD"
},
"BillDate": {
"value": "2021-08-25T00:00:00+00:00"
},
"Branch": {
"value": "BOE"
},
"ControlQty": {
"value": 2.000000
},
"CreateBill": {
"value": false
},
"CurrencyEffectiveDate": {
"value": "2020-12-29T00:00:00+00:00"
},
"CurrencyID": {
"value": "CAD"
},
"CurrencyRate": {
"value": 1.00000000
},
"CurrencyRateTypeID": {},
"CurrencyReciprocalRate": {
"value": 1.00000000
},
"Date": {
"value": "2021-08-25T00:00:00+00:00"
},
"Details": [
{
"id": "d5c53b1c-0b06-ed11-8312-0a72f5e849b2",
"rowNumber": 1,
"note": {
"value": ""
},
"Account": {
"value": "5000"
},
"AccrualAccount": {
"value": "2000"
},
"AccrualSubaccount": {
"value": "000"
},
"Branch": {
"value": "BOE"
},
"Description": {
"value": "Cost of Purchase"
},
"EditableUnitCost": {
"value": true
},
"EstimatedINExtendedCost": {
"value": 312.0000
},
"ExtendedCost": {
"value": 312.0000
},
"FinalINExtendedCost": {},
"InventoryID": {
"value": "E10003"
},
"LineNbr": {
"value": 1
},
"LineType": {
"value": "Non-Stock"
},
"OpenQty": {
"value": 0.0
},
"OrderedQty": {
"value": 1.000000
},
"POLineNbr": {
"value": 1
},
"POOrderNbr": {
"value": "000003"
},
"POOrderType": {
"value": "Normal"
},
"POReceiptLineNbr": {},
"POReceiptNbr": {},
"ReceiptQty": {
"value": 33.000000
},
"Subaccount": {
"value": "000"
},
"TransactionDescription": {
"value": "Ladder - 24' Aluminum Extension Ladder"
},
"TransferOrderLineNbr": {},
"TransferOrderNbr": {},
"TransferOrderType": {},
"TransferShipmentNbr": {},
"UnitCost": {
"value": 22.0000
},
"UOM": {
"value": "EA"
},
"custom": {}
}
],
"Hold": {
"value": true
},
"Location": {
"value": "MAIN"
},
"PostPeriod": {
"value": "082021"
},
"ProcessReturnWithOriginalCost": {
"value": false
},
"ReceiptNbr": {
"value": "000138"
},
"Status": {
"value": "On Hold"
},
"TotalCost": {
"value": 213.0000
},
"TotalQty": {
"value": 2.000000
},
"Type": {
"value": "Receipt"
},
"UnbilledQuantity": {
"value": 2.000000
},
"VendorID": {
"value": "GROPWA"
},
"VendorRef": {},
"custom": {},
"files": [
{
"id": "6f621043-a8z4-4a89-b34f-910d399e31c0",
"filename": "Purchase Receipts (RT, 000138)\\Sample.txt",
"href": "/entity/Purchasing/20.200.001/files/6f621043-a8z4-4a89-b34f-910d399e31c0"
}
]
}
Below is the error response received after attempting to update:
{
"message": "An error has occurred.",
"exceptionMessage": "Sequence contains no matching element",
"exceptionType": "System.InvalidOperationException",
"stackTrace": " at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)\r\n at PX.Api.ContractBased.EntityExportContextBuilder.ExtractFieldMappingKeyForDetail(String mappingKey, EntityField field, EntityMappingProjection[] entityFields, IMetadataProvider metadataProvider, IEntityMappingKeyService entityMappingKeyService, String endpointName, String version)\r\n at PX.Api.ContractBased.EntityExportContextBuilder.EntityFieldsOrderComparer.Compare(EntityField x, EntityField y)\r\n at System.Linq.EnumerableSorter`2.CompareKeys(Int32 index1, Int32 index2)\r\n at System.Linq.EnumerableSorter`1.QuickSort(Int32[] map, Int32 left, Int32 right)\r\n at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count)\r\n at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()\r\n at PX.Api.ContractBased.EntityExportContextBuilder.BuildPutCommands(EntityImpl entity, String mappingKey, Boolean newEntity, EntityMappingProjectionWrapper[] orderedMappedFields, ISet`1 preProcessedFields, Boolean isDetail)\r\n at PX.Api.ContractBased.EntityExportContextBuilder.BuildContextForPutOrInvoke(EntityDescriptor descriptor, Boolean isNewEntity, Action`2 appendActionsDelegate)\r\n at PX.Api.ContractBased.EntityService.Put(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext, Boolean throwOnError)\r\n at PX.Api.ContractBased.Soap.SoapFacadeBase.PutImpl(EntityImpl entity, Boolean throwOnValidationError)\r\n at PX.Api.ContractBased.SystemContracts.V2.RestController.PutEntity(EntityImpl entity, String select, String filter, String expand, String custom)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"
}

Agree with Samvel, seperate request. Also use the below to push the stream/file to the entity:
var response = _httpClient.PutAsync(_httpClient.BaseAddress + entityName + "/" + keys + "/files/" + fileName, new StreamContent(file)).Result;

I am not sure what the issue is with your request but I would recommend that you only send the fields that you need to update through the PUT request.
That error seems to be hinting that you are trying to update an entity or sub entity that it cannot find. This would mean that either the id GUID field values or the key field values that you are sending do not exist in the system.
There are 3 id field that you might want to check to see if the value is still the same.
But Once again I will put an emphasis on the fact that if you do not want to Update a field do not send it through the API. That will probably solve the issue that you are facing.

Related

Rest API SalesOrder with Payment

I am trying to enter a sales order with a payment against 2019R2, which from the demo's I've seen should work, however I receive a fairly useless exception message:
{
"message": "An error has occurred.",
"exceptionMessage": "Operation failed",
"exceptionType": "PX.Data.PXInvalidOperationException",
"stackTrace": " at PX.Api.ContractBased.EntityService.Put(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext, Boolean throwOnError)\r\n at PX.Api.ContractBased.Soap.SoapFacadeBase.PutImpl(EntityImpl entity, Boolean throwOnValidationError)\r\n at PX.Api.ContractBased.SystemContracts.V2.RestController.PutEntity(EntityImpl entity, String select, String filter, String expand, String custom)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()",
"innerException": {
"message": "An error has occurred.",
"exceptionMessage": "Exception has been thrown by the target of an invocation.",
"exceptionType": "System.Reflection.TargetInvocationException",
"stackTrace": " at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)\r\n at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)\r\n at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\r\n at PX.Api.ContractBased.EntityExportContextBuilder.<>c__DisplayClass87_1.<FindImplementations>b__3(PXGraph graph, EntityImpl entity, EntityImpl targetEntity)\r\n at PX.Api.SyImportProcessor.SyStep.ProcessCommand(SyCommand cmd, Boolean& needCommit)\r\n at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable()",
"innerException": {
"message": "An error has occurred.",
"exceptionMessage": "Inserting 'AR Payment' record raised at least one error. Please review the errors.",
"exceptionType": "PX.Data.PXOuterException",
"stackTrace": " at PX.Data.PXUIFieldAttribute.CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)\r\n at PX.Data.PXCache.OnCommandPreparing(String name, Object row, Object value, PXDBOperation operation, Type table, FieldDescription& description)\r\n at PX.Data.PXTableAttribute.PrepareParametersForInsert(PXCache sender, Object row, Type[] tables, ISqlDialect dialect, Boolean audit, List`1[] pars)\r\n at PX.Data.PXTableAttribute.PersistInserted(PXCache sender, Object row)\r\n at PX.Data.PXCache`1.PersistInserted(Object row, Boolean bypassInterceptor)\r\n at PX.Data.PXCache`1.Persist(PXDBOperation operation)\r\n at PX.Data.PXGraph.Persist(Type cacheType, PXDBOperation operation)\r\n at PX.Data.PXGraph.Persist()\r\n at PX.Objects.AR.ARPaymentEntry.Persist()\r\n at PX.Data.PXSave`1.<Handler>d__2.MoveNext()\r\n at PX.Data.PXAction`1.<Press>d__28.MoveNext()\r\n at PX.Data.PXAction`1.<Press>d__28.MoveNext()\r\n at PX.Data.PXAction`1.PressImpl(Boolean internalCall, Boolean externalCall)\r\n at PX.Data.PXAction`1.Press()\r\n at PX.Objects.EndpointAdapters.DefaultEndpointImpl18.Payments_Insert(PXGraph graph, EntityImpl entity, EntityImpl targetEntity)"
}
}
}
The Following was the request made:
{
"CashAccount" : {"value" : "MERCHANT"},
"OrderType" : {"value" : "SO"},
"CustomerID" : {"value" : "35"},
"CustomerOrder" : {"value" : "1"},
"DisableAutomaticDiscountUpdate" : {"value" : true},
"Description" : {"value" : "ecommerce order"},
"LocationID" : {"value" : "MAIN"},
"Details" : [
{
"rowNumber" : 1,
"InventoryID" : {"value" : "item1"},
"UnitPrice" : {"value" : 320.00},
"SalesAcctID" : {"value" : "40200"},
"UOM" : {"value" : "EA"},
"OrderQty" : {"value" : "1.0000"}
}
],
"BillToContactOverride" : {"value" : true},
"BillToContact" : {
"rowNumber" : 1,
"Attention" : {"value" : "Joe DiMaggio"},
"BusinessName" : {"value" : "Major League Baseball"},
"Email" : {"value" : "joe#baseball.fun"},
"Phone1" : {"value" : "877-123-4567"}
},
"BillToAddressOverride" : {"value" : true},
"BillToAddress" : {
"rowNumber" : 1,
"AddressLine1" : {"value" : "123 Main Street"},
"AddressLine2" : {"value" : "attn: team manager"},
"City" : {"value" : "Los Angeles"},
"Country" : {"value" : "US"},
"State" : {"value" : "CA"},
"PostalCode" : {"value" : "91324"}
},
"ShipToContactOverride" : {"value" : true},
"ShipToContact" : {
"rowNumber" : 1,
"Attention" : {"value" : "Joe DiMaggio"},
"BusinessName" : {"value" : "Major League Baseball"},
"Email" : {"value" : "joe#baseball.fun"},
"Phone1" : {"value" : "877-123-4567"}
},
"ShipToAddressOverride" : {"value" : true},
"ShipToAddress" : {
"rowNumber" : 1,
"AddressLine1" : {"value" : "123 Main Street"},
"AddressLine2" : {"value" : "attn: team manager"},
"City" : {"value" : "Los Angeles"},
"Country" : {"value" : "US"},
"State" : {"value" : "CA"},
"PostalCode" : {"value" : "91324"}
},
"ShipVia" : {"value" : "FEDEXGRND"},
"ShippingSettings" : {
"ShippingTerms" : {"value" : "WEBORDER"},
"ShipVia" : {"value" : "FEDEXGRND"}
},
"Status" : {"value" : "open"},
"TaxTotal" : {"value" : 24.80},
"Totals" : {
"PremiumFreight" : {"value" : 6.00},
"FreightTaxCategory" : {"value" : "FR020100"}
},
"Payments" : [{
"AppliedToOrder" : {"value" : 326.00},
"CashAccount" : {"value" : "MERCHANT"},
"PaymentAmount" : {"value" : 326.00},
"DocType" : {"value" : "Prepayment"},
"PaymentMethod" : {"value" : "CC"},
"PaymentRef" : {"value" : "12345"}
}]
}
The Order is successfully entered when I submit this, however the payment is not. Tried various combinations in the Payments field. I know one suggestion is to get a sales order record and use $expand to get the sub data, however adding Payments to $expand does not work, it returns an empty array, even on order which have payments recorded.
I've tried several combinations in the Payments array, tried recording multiple payments at the same time, tried not applying the payments, or applying only $1. Tried Payment and Prepayment doctypes. The only thing that works is if I pre-enter a payment I can use that payment's ReferenceNbr to apply an amount to the order, however that isn't what is described in the documentation or video demo I've seen.
Anyone have an real life working example of this? I'd prefer the enter ecommerce transactions in a single request, and not have to use 2 requests to enter sales order then payment.

getting AccessToken, VerifySmsToken mscorlib "Unable to connect to the remote server",

I get this error when I am posting via postman.
Other methods work perfectly. Just this method, that addresses the user verification and its response is an access token, has error.
I think the length of the string token is the origin of the error.
Post man response :
"StackTrace": " at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\r\n at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)\r\n at System.Threading.Tasks.Task`1.get_Result()\r\n at FactoryJaApi.Controllers.UserController.<Login>d__14.MoveNext() \r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at FactoryJaApi.Controllers.UserController.d__12.MoveNext()
"TargetSite": {
"Name": "ThrowIfExceptional",
"AssemblyName": "mscorlib, Version=4.0.0.0, Culture=neutral,
"ClassName": "System.Threading.Tasks.Task",
"Signature": "Void ThrowIfExceptional(Boolean)",
"Signature2": "System.Void ThrowIfExceptional(System.Boolean)",
"MemberType": 8,
"GenericArguments": null
},
"ErrorLine": null,
"ExceptionType": "System.AggregateException",
"ExceptionUrl": null,
"InnerException": {
"DateTime": "0001-01-01T00:00:00",
"Message": "An error occurred while sending the request.",
"HelpLink": null,
"Source": null,
"StackTrace": null,
"TargetSite": null,
"ErrorLine": null,
"ExceptionType": null,
"ExceptionUrl": null,
"InnerException": {
"DateTime": "0001-01-01T00:00:00",
"Message": "Unable to connect to the remote server",
"HelpLink": null,
"Source": null,
"StackTrace": " at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)\r\n at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)",
"TargetSite": null,
"ErrorLine": null,
"ExceptionType": null,
"ExceptionUrl": null,
"InnerException": null
}
}
}
}
Thank all of you that your information does not help me and was far from my ask.
I pointed this error just happens on verifying and generating token string method. and other method work perfectly and correct.
Token method has a self-Query on itself . so when your query goes to server Kaarix.work , IIS cannot access to same address from interior. for Solving : just you need to define a redirection local url and redirect your queries that call from inside machine.
See the screenshot if you need the answer.
enter image description here

Stream Analytics Job deployed as Azure Resource Manager (ARM) template

I am trying to setup an output EventHub for a Stream Analytics Job defined as a JSON template. Without the output bit the template is successfully deployed, however when adding the output definition it fails with:
Deployment failed. Correlation ID: <SOME_UUID>. {
"code": "BadRequest",
"message": "The JSON provided in the request body is invalid. Property 'eventHubName' value 'parameters('eh_name')' is not acceptable.",
"details": {
"code": "400",
"message": "The JSON provided in the request body is invalid. Property 'eventHubName' value 'parameters('eh_name')' is not acceptable.",
"correlationId": "<SOME_UUID>",
"requestId": "<SOME_UUID>"
}
}
I've defined the ARM template as:
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "westeurope"
},
"hubName": {
"type": "string",
"defaultValue": "fooIotHub"
},
"eh_name": {
"defaultValue": "fooEhName",
"type": "String"
},
"eh_namespace": {
"defaultValue": "fooEhNamespace",
"type": "String"
},
"streamAnalyticsJobName": {
"type": "string",
"defaultValue": "fooStreamAnalyticsJobName"
}
},
"resources": [{
"type": "Microsoft.StreamAnalytics/StreamingJobs",
"apiVersion": "2016-03-01",
"name": "[parameters('streamAnalyticsJobName')]",
"location": "[resourceGroup().location]",
"properties": {
"sku": {
"name": "standard"
},
"outputErrorPolicy": "Drop",
"eventsOutOfOrderPolicy": "adjust",
"eventsOutOfOrderMaxDelayInSeconds": 0,
"eventsLateArrivalMaxDelayInSeconds": 86400,
"inputs": [{
"Name": "IoTHubInputLable",
"Properties": {
"DataSource": {
"Properties": {
"iotHubNamespace": "[parameters('hubName')]",
"sharedAccessPolicyKey": "[listkeys(resourceId('Microsoft.Devices/IotHubs/IotHubKeys',parameters('hubName'), 'iothubowner'),'2016-02-03').primaryKey]",
"sharedAccessPolicyName": "iothubowner",
"endpoint": "messages/events"
},
"Type": "Microsoft.Devices/IotHubs"
},
"Serialization": {
"Properties": {
"Encoding": "UTF8"
},
"Type": "Json"
},
"Type": "Stream"
}
}],
"transformation": {
"name": "Transformation",
"properties": {
"streamingUnits": 1,
"query": "<THE SQL-LIKE CODE FOR THE JOB QUERY>"
}
},
"outputs": [{
"name": "EventHubOutputLable",
"properties": {
"dataSource": {
"type": "Microsoft.ServiceBus/EventHub",
"properties": {
"eventHubName": "parameters('eh_name')",
"serviceBusNamespace": "parameters('eh_namespace')",
"sharedAccessPolicyName": "RootManageSharedAccessKey"
}
},
"serialization": {
"Properties": {
"Encoding": "UTF8"
}
}
}
}]
}
}]
}
Checking here https://learn.microsoft.com/en-us/azure/templates/microsoft.streamanalytics/streamingjobs
it looks like the structure of the JSON for the output is as the expected one (with the properties field along with the type).
I've figured out those "Event Hub properties" from the Chrome browser using Developer Tools and checking the details of the HTTP request "GetOutputs", otherwise I am not sure where I could see how to specify those properties? The structure looks quite similar to the one for the input IoT Hub (which is working), in that case using different lables for the properties related to the IoT Hub details.
Checking this blog post https://blogs.msdn.microsoft.com/david/2017/07/20/building-azure-stream-analytics-resources-via-arm-templates-part-2-the-template/
the output part is related to PowerBI and it looks like a different structure is used for the properties: outputPowerBISource, so I've tried to use for the Event Hub the field outputEventHubSource (from the checks using Chrome Developer Tools) instead of properties, but then I get this error:
Deployment failed. Correlation ID: <SOME_UUID>. {
"code": "BadRequest",
"message": "The JSON provided in the request body is invalid. Required property 'properties' not found in JSON. Path '', line 1, position 1419.",
"details": {
"code": "400",
"message": "The JSON provided in the request body is invalid. Required property 'properties' not found in JSON. Path '', line 1, position 1419.",
"correlationId": "<SOME_UUID>",
"requestId": "<SOME_UUID>"
}
}
The command I am using to deploy this template is the Azure CLI (from a Linux Debian machine):
az group deployment create \
--name "deployStreamAnalyticsJobs" \
--resource-group "MyRGName" \
--template-file ./templates/stream-analytics-jobs.json
How do I specify an output in an Azure Resource Manager (ARM) template for a Stream Analytics Job?
Any property that contains a parameter (or any expression that needs to be evaluated must contain square brackets, e.g.
"eventHubName": "[parameters('eh_name')]",
"serviceBusNamespace": "[parameters('eh_namespace')]",
Otherwise the literal value in the quotes is used.
That help?
I found out all parameters need to be wrapped in square brakets (as pointed out in the other answer to this question).
Also to dynamically retrieve the shared access policy key (or any other parameter for an existing resource like the Event Hub) a combination of functions like listKeys and resourceId etc must be used, see below for a full example of an Event Hub described as an output for a Stream Analytics Job.
In details:
the parameters defined for eventHubName and serviceBusNamespace must be evaluated using square brackets (see how I defined those parameters in the JSON example in the body of the question I asked above),
the shared access policy could be either an hardcoded string (or a parameter as before) like sharedAccessPolicyName or dynamically retrieved using "sharedAccessPolicyKey": "[listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', parameters('eh_namespace'), parameters('eh_name'), 'RootManageSharedAccessKey'),'2017-04-01').primaryKey]" for the sharedAccessPolicyKey (this is sensitive data and it should be protected avoiding hardcoding information as a plain string)
The following JSON configuration shows an existing Event Hub defined as an output defined for the Stream Analytics Job:
"outputs": [{
"Name": "EventHubOutputLable",
"Properties": {
"DataSource": {
"Type": "Microsoft.ServiceBus/EventHub",
"Properties": {
"eventHubName": "[parameters('eh_name')]",
"serviceBusNamespace": "[parameters('eh_namespace')]",
"sharedAccessPolicyKey": "[listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', parameters('eh_namespace'), parameters('eh_name'), 'RootManageSharedAccessKey'),'2017-04-01').primaryKey]",
"sharedAccessPolicyName": "RootManageSharedAccessKey"
}
},
"Serialization": {
"Properties": {
"Encoding": "UTF8"
},
"Type": "Json"
}
}
}]

Azure Resource Management REST API for Bot Framework DirectLine Channel Configuration

I'm trying to add a Site to my DirectLine channel in my Azure Bot Registration via the REST APIs. When I perform a GET against the following ARM REST URL, I get a JSON payload with any existing sites listed.
https://management.azure.com/subscriptions/{azure.SubscriptionId}/resourceGroups/{MyResourceGroupName}/providers/Microsoft.BotService/botServices/{MyBotHandle}/channels/DirectLineChannel?api-version=2017-12-01
If I then take the JSON output from the GET call and add a Site to it like this...
{
"id": "/subscriptions/{SubscriptionID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.BotService/botServices/{BotHandle}/channels/DirectLineChannel",
"name": "{BotHandle}/DirectLineChannel",
"type": "Microsoft.BotService/botServices/channels",
"etag": "W/\"8e7678d65f7dbeea8863f0c68af75f606/6/2018 6:31:37 PM\"",
"location": "global",
"properties": {
"properties": {
"DirectLineEmbedCode": null,
"sites": [
{
"siteId": "uXuynMwVIBI",
"siteName": "Default Site",
"key": "uXuynMwVIBI.cwA.ve8.m2IbJ0McgjmxAq8vlZ1ZY1jAFdpdQj14GbgrS4z-qpA",
"key2": "uXuynMwVIBI.cwA.gXE.4aZw5_DIJuLPsQ2zjIYSCMztTxUxNpX4trwfO-6Gb9k",
"isEnabled": true,
"isV1Enabled": true,
"isV3Enabled": true
}
]
},
"etag": "W/\"8e7678d65f7dbeea8863f0c68af75f606/6/2018 6:31:37 PM\"",
"channelName": "DirectLineChannel",
"location": "global",
"provisioningState": "Succeeded"
}
}
... and then perform a PUT against the same initial URL, I get the following error:
An unexpected error occurred. Exception: 'Microsoft.Bot.Schema.APIException: Empty service error response. ID: \r\n at Intercom.Channels.Models.Shared.TimeLimitedConfigHttpClient1.<GetFromResponseAsync>d__20.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Intercom.Channels.Models.Shared.TimeLimitedConfigHttpClient1.d__10.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Intercom.Channels.Models.Shared.ConfigApi1.<PutAsync>d__7.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()\r\n at Intercom.ResourceProvider.Channels.ArmChannelManager.d__22.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()\r\n at Intercom.ResourceProvider.DataProviders.ChannelResourceDataProvider.d__5.MoveNext()'.
I noticed this JSON looks like an ARM template as well so I tried adding it to a deployment and I get the exact same error above. It provisions the bot and then I get an InternalServerError when it's provisioning the DirectLineChannel. The Operation details link gives me the above error.
Any thoughts on how to do this? Am I way off?
Thanks!

Unable to create azure.createQueueService() in Azure Function App

I want to go through the queue data in Azure queue storage in a HTTP trigger function App.
I add the "äzure-storage" Node.js package and using following code:
var azure = require('azure-storage');
But either the code var queueSvc = azure.createQueueService(); or var queueSvc = azure.createQueueService(<storage connection string>); is failure when execute the function. I got below exception
"reason": "PassThrough",
"exception": {
"ClassName": "System.Threading.Tasks.TaskCanceledException",
"Message": "A task was canceled.",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": " at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at AzureFunctions.Code.PassThroughRequestManager.d__2.MoveNext()",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": "8\nThrowForNonSuccess\nmscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Runtime.CompilerServices.TaskAwaiter\nVoid ThrowForNonSuccess(System.Threading.Tasks.Task)",
"HResult": -2146233029,
"Source": "mscorlib",
"WatsonBuckets": null
}
}
I can't reproduce this issue in a simple HTTP trigger function with Javascript:
Install azure-storage via Kudu debug console (https://<functionname>.scm.azurewebsites.net/DebugConsole):
In the index.js file I have this:

Resources