Skip to content

service returning json.decoder.JSONDecodeError with PUT/PATCH request #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TerriblyVexed opened this issue Dec 3, 2021 · 1 comment

Comments

@TerriblyVexed
Copy link

TerriblyVexed commented Dec 3, 2021

I have implemented this in my Azure environment. GET/DELETE work. PUT/PATCH do not. I keep getting:
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)'

returned from the Log Stream when I input:
curl -s -X PATCH https://{mysite}.azurewebsites.net/nordicid/6223F1E1-A9A0-403B-82C1-00BA031832D7 -d 'nordicpersonid={"PersonNameLast": "Abshireo"}'

I'm just trying to update the person last name.

flask==1.1.4 (was getting opencensus-ext-flask error with 2.0)

Table definition:
CREATE TABLE [dbo].[NordicID]( [NordicPersonID] [uniqueidentifier] NOT NULL, [PersonNameLast] [varchar](50) NULL, [PersonNameFirst] [varchar](50) NULL, [OtherEntityType] [char](50) NULL, [OtherEntityName] [char](50) NULL, [OtherEntityID] [int] NOT NULL, [CreatedDate] [datetime] NOT NULL,

proc definition:
CREATE OR ALTER PROCEDURE web.patch_NordicID @Json NVARCHAR(MAX) AS SET NOCOUNT ON; DECLARE @NordicID UNIQUEIDENTIFIER = JSON_VALUE(@Json, '$.NordicPersonID'); WITH [source] AS ( SELECT * FROM OPENJSON(@Json) WITH ( [NordicPersonID] UNIQUEIDENTIFIER, [PersonNameLast] VARCHAR(50), [PersonNameFirst] VARCHAR(50), [OtherEntityType] CHAR(50), [OtherEntityName] CHAR(50), [OtherEntityID] INT, [CreatedDate] DATETIME ) ) UPDATE t SET t.[PersonNameLast] = COALESCE(s.[PersonNameLast], t.[PersonNameLast]), t.[PersonNameFirst] = COALESCE(s.[PersonNameFirst], t.[PersonNameFirst]), t.[OtherEntityType] = COALESCE(s.[OtherEntityType], t.[OtherEntityType]), t.[OtherEntityName] = COALESCE(s.[OtherEntityName], t.[OtherEntityName]), t.[OtherEntityID] = COALESCE(s.[OtherEntityID], t.[OtherEntityID]), t.[CreatedDate] = COALESCE(s.[CreatedDate], t.[CreatedDate]) FROM [Wellward].[NordicID] t INNER JOIN [source] s ON t.[NordicPersonID] = s.[NordicPersonID] WHERE t.NordicPersonID = @NordicID; DECLARE @Json2 NVARCHAR(MAX) = N'{"NordicPersonID": "' + CAST(@NordicID AS NVARCHAR(255)) + N'"}' EXEC web.get_NordicID @Json2;

parser and patch def with my notes in application.py:
parser.add_argument('nordicpersonid', type=str) def patch(self, nordic_id): # nordic_id = function parms args = parser.parse_args() nordic = json.loads(args['nordicpersonid']) nordic["NordicID"] = nordic_id # this builds the payload; 'NordicID' = tablename, nordic_id = parm result = self.executeQueryJson("patch", nordic) # procedure/verb, payload return result, 202

routes:
api.add_resource(NordicID, '/nordicid', '/nordicid/<nordic_id>') # nordicid = procname suffix, nordic_id = parm
requirements.txt
application.txt

@TerriblyVexed
Copy link
Author

just figured it out. it was PowerShell "handling" the double quotes. instead of " I needed /" in my curl call from posh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant