The ConnectionString option in appsettings.json file giving parse error after deployed under IIS - asp.net-core-mvc

I am working on an ASP.NET Core MVC project. In appsettings.json file, I have the following connection string:
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"LabConnectionString": "Server=1234-98761\SQLEXPRESS;Database=db;Trusted_Connection=True;MultipleActiveResultSets=true;",
"providerName": "System.Data.SqlClient"
}
}
It is working fine when the project is executed from Visual Studio. But when it is deployed in the IIS server after compiling, I am getting the following error found in a log file:
Unhandled Exception: System.FormatException: Could not parse the JSON file. Error on line number '9': '"ConnectionStrings": {
"LabConnectionString": "data source=1234-98761;initial catalog=db;Trusted_Connection=True;MultipleActiveResultSets=true;",'.
Newtonsoft.Json.JsonReaderException: Bad JSON escape sequence: \S. Path 'ConnectionStrings.LabConnectionString', line 9, position 52.
Thanks

Just add double back slashes\\ before SQLEXPRESS. Update your code like below:-
"LabConnectionString": "Server=1234-98761\\SQLEXPRESS;Database=db;Trusted_Connection=True;MultipleActiveResultSets=true;",
and your startup.cs file:-
services.AddControllers().AddNewtonsoftJson()
Hope It will resolve your issue.

In JSON format, inside a string the backslash character is used as escape for other special character, and for itself too.
Here is a self explanatory image from Douglas Crockford's and ECMA's JSON specs
So, you have to escape the backslash:
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"LabConnectionString": "Server=1234-98761\\SQLEXPRESS;Database=db;Trusted_Connection=True;MultipleActiveResultSets=true;",
"providerName": "System.Data.SqlClient"
}
}

Related

Sharing app content to stage - Insufficient RSC permission

sharing the content of our app hasn't worked for a week.
Using the Teams WebApp we are getting the following errors in the developer console:
CID[main] ShareExtensibleAppButtonContainer: Installed app is undefined or doesn't have authorization
Insufficient RSC permission for appId:'XXXXXXX' with isChannelMeeting: false
it worked last month, and nothing was changed from our side.
I tried to set the following permissions, but it has had no effect.
"authorization": {
"permissions": {
"orgWide": [],
"resourceSpecific": [
{
"name": "MeetingStage.Write.Chat",
"type": "Delegated"
},
{
"name": "ChannelMeetingStage.Write.Group",
"type": "Delegated"
}
]
}
}
could anyone help me to get it working?
Thank you

Automate Dbeaver SQL Export

Dbeaver recently pushed an update to allow you to code an export. The documentation lists the export function as
#export {"type": "csv", "producer": {...}, "consumer": {...}, "processor": {...}}
I'm not sure how to format this to get the code to run. The JSON text in the documentation looks like the following:
{
"type": <ID of the processor>,
"producer": {
<producer settings>
},
"consumer": {
<consumer settings>
},
"processor": {
<processor-specific settings>
},
}
I'm aiming to get the code to output data to a folder and file name. The associated IDs are outputFolder and outputFilePattern which belong in the consumer settings. I've tried various permutations to get this to work, but receive errors like unterminated object at outputFolder, expecting ':' at outputFolder, invalid syntax, etc. The most obvious permutation is:
#export {"type": "csv", "producer": {}, "consumer": {"outputFolder": "C:\downloads", "outputFilePattern": "Data"}, "processor": {...}}
This returns the error 'invalid escape sequence at column 52 path $..outputFolder'. If you don't put quotes around outputFolder it returns the same error.
https://dbeaver.com/docs/wiki/Export-Command/#Producer-Settings

Issues getting flow to send the correct json in body when using powerautomate's http request

I'm using a PowerAutomate Flow to call a native SmartSheet API that does a POST. The POST IS working but my MULTI_PICKLIST type field is not being populated correctly in SmartSheet due to the double quotes.
The API is: concat('https://api.smartsheet.com/2.0/sheets/', variables('vSheetID'), '/rows')
In the Body section of the http rest API I form my JSON and the section of interest looks like this:
{
"columnId": 6945615984781188,
"objectValue": {
"objectType": "MULTI_PICKLIST",
"values": [
#{variables('vServices')}
]
}
}
My variable vServices raw output looks like:
{
"body":
{
"name": "vServices",
"value": "Test1, Test2"
}
}
The format needs to be like this (it works using PostMan).
{
"columnId": 6945615984781188,
"objectValue": {
"objectType": "MULTI_PICKLIST",
"values": [
"Test1","Test2"
]
}
}
As a step in formatting my vServices variable I tried to do a replace function to replace the ',' with a '","' but this ultimately ends up as a \",\"
Any suggestion on how to get around this? Again, ultimately I need the desired JSON Body to read but haven't been able to achieve this in the Body section:
{
"columnId": 6945615984781188,
"objectValue": {
"objectType": "MULTI_PICKLIST",
"values": [
"Test1","Test2"
]
}
}
vs this (when using replace function).
{
"columnId": 6945615984781188,
"objectValue": {
"objectType": "MULTI_PICKLIST",
"values": [
"Test1\",\"Test2"
]
}
}
Thank you in advance,
I resolved my issue by taking the original variable, sending it to a compose step that did a split on the separator of a comma. I then added a step to set a new variable to the output of the compose step. This left me with a perfectly setup array in the exact format I needed! This seemed to resolve any of the issues I was having with double quotes and escape sequences.

Storage Transfer Service transferJobs.patch API does not work for nested object

Problem you have encountered:
Following steps at link below for transferJobs.patch API
https://cloud.google.com/storage-transfer/docs/reference/rest/v1/transferJobs/patch
Patch API works as expected if want to update description. Sample Below
Request:
{
"projectId": "<MY_PROJECT>",
"transferJob": {
"transferSpec": {
"objectConditions": {
"lastModifiedSince": "2022-01-24T18:30:00Z"
}
},
"description": "updated description"
},
"updateTransferJobFieldMask": "description"
}
Response: Success 200
Patch API do not work if want to update nested object field. Sample Below
{
"projectId": "<MY_PROJECT>",
"transferJob": {
"transferSpec": {
"objectConditions": {
"lastModifiedSince": "2022-01-22T18:30:00Z"
}
},
"description": "updated description"
},
"updateTransferJobFieldMask": "transferSpec.objectConditions.lastModifiedSince"
}
Response: 400
{"error": {
"code": 400,
"message": "Invalid path in the field mask.",
"status": "INVALID_ARGUMENT"}}
Tried other combinations following documentation/sample code reference but none of them work. Tried options as
transferSpec.objectConditions.lastModifiedSince
transferJob.transferSpec.objectConditions.lastModifiedSince
objectConditions.lastModifiedSince lastModifiedSince Snake case
combination referring to FieldMaskUtil as transfer_spec.object_conditions.last_modified_since
What I expected to happen:
Patch API to work successfully for nested object as per documentation I.e. "updateTransferJobFieldMask": "transferSpec.objectConditions.lastModifiedSince"
updateTransferJobFieldMask works on the top level object, in this case transferSpec.
Changing that line to updateTransferJobFieldMask: transferSpec should work.
From the documentation:
The field mask of the fields in transferJob that are to be updated in this request. Fields in transferJob that can be updated are: description, transfer_spec, notification_config, and status. To update the transfer_spec of the job, a complete transfer specification must be provided. An incomplete specification missing any required fields will be rejected with the error INVALID_ARGUMENT.
Providing complete object having required child field worked. Sample example for future reference to other dev.
Below job transfer dat from Azure to GCP bucket and during patch updating last modified time. Both transfer_spec and transferSpec works as updateTransferJobFieldMask.
{
"projectId": "<MY_PROJECT>",
"updateTransferJobFieldMask": "transfer_spec",
"transferJob": {
"transferSpec": {
"gcsDataSink": {
"bucketName": "<BUCKET_NAME>"
},
"objectConditions": {
"lastModifiedSince": "2021-12-30T18:30:00Z"
},
"transferOptions": {},
"azureBlobStorageDataSource": {
"storageAccount": "<ACCOUNT_NAME>",
"container": "<CONTAINER>",
"azureCredentials": {
"sasToken": "<SAS TOKEN>"
}
}
}
}
}

Duplicated mapping key in serverless.yml

I'm using Serverless to deploy a couple of functions written in C# to AWS.
While deploying a message duplicated mapping key in "...\serverless.yml" is thrown.
Separately, both functions get deployed but when put together the said error message is shown.
What am I missing?
{
"service": "serverlessquick",
"provider": {
"name": "aws",
"runtime": "nodejs4.3"
},
"functions": {
"hello": {
"handler": "handler.hello",
"events": [
{
"http": {
"path": "hello",
"method": "get"
}
}
]
}
}
}
Make your yaml code into json this way any mistakes are obvious, and will be more likely to be picked up by the parser. If anyone comes across this, use the referenced config above.
I got a similar error but in my case it was indentation problem. Go through your YML file and see if the changes you have made have the correct identation. A json parser as mention by others can help narrow down where in the YML file the problem exists

Resources