Escape JSON Data in POST:

I am struggling to use Curl from mingw64 to POST JSON to my localhost.

Fenced code block:

curl -H 'Content-Type: application/csp-report;charset=utf-8' 
--data '{"csp-report":{"document-uri":"https://localhost/test",
"referrer":"https://www.google.com/",
"violated-directive":"default-src self","original-policy":"default-src self; report-uri /csp.php",
"blocked-uri":"http://evilhackerscripts.com"}}' 
'https://localhost/csp.php'

Error Message:

Notice: Trying to get property ‘csp-report’ of non-object in C:\www\testing\csp.php on line 11

Notice: Trying to get property ‘document-uri’ of non-object in C:\www\testing\csp.php on line 11

Notice: Trying to get property ‘csp-report’ of non-object in C:\www\testing\csp.php on line 12

Notice: Trying to get property ‘referrer’ of non-object in C:\www\testing\csp.php on line 12

Notice: Trying to get property ‘csp-report’ of non-object in C:\www\testing\csp.php on line 13

Notice: Trying to get property ‘violated-directive’ of non-object in C:\www\testing\csp-reporter.php on line 13

Notice: Trying to get property ‘csp-report’ of non-object in C:\www\testing\csp.php on line 14

Notice: Trying to get property ‘original-policy’ of non-object in C:\www\testing\csp.php on line 14

Notice: Trying to get property ‘csp-report’ of non-object in C:\www\testing\csp.php on line 15

Notice: Trying to get property ‘blocked-uri’ of non-object in C:\www\testing\csp.php on line 15

I am facing an issue while trying to POST JSON to my localhost using Curl from mingw64. When running the following command, I am receiving the following error message:

Fenced code block:

curl -H 'Content-Type: application/csp-report;charset=utf-8' 
--data '{"csp-report":{"document-uri":"https://localhost/test",
"referrer":"https://www.google.com/",
"violated-directive":"default-src self","original-policy":"default-src self; report-uri /csp.php",
"blocked-uri":"http://evilhackerscripts.com"}}' 
'https://localhost/csp.php'

Error Message:

Notice: Trying to get property ‘csp-report’ of non-object in C:\www\testing\csp.php on line 11

Notice: Trying to get property ‘document-uri’ of non-object in C:\www\testing\csp.php on line 11

Notice: Trying to get property ‘csp-report’ of non-object in C:\www\testing\csp.php on line 12

Notice: Trying to get property ‘referrer’ of non-object in C:\www\testing\csp.php on line 12

Notice: Trying to get property ‘csp-report’ of non-object in C:\www\testing\csp.php on line 13

Notice: Trying to get property ‘violated-directive’ of non-object in C:\www\testing\csp-reporter.php on line 13

Notice: Trying to get property ‘csp-report’ of non-object in C:\www\testing\csp.php on line 14

Notice: Trying to get property ‘original-policy’ of non-object in C:\www\testing\csp.php on line 14

Notice: Trying to get property ‘csp-report’ of non-object in C:\www\testing\csp.php on line 15

Notice: Trying to get property ‘blocked-uri’ of non-object in C:\www\testing\csp.php on line 15

The error message you are receiving indicates that the issue is with the csp.php script that you are trying to POST the JSON to. It seems that the script is expecting an object with a property csp-report, but it is not receiving it.

You can try to modify your curl command and add the --verbose option to see more details about the response. You can also try to modify the csp.php script and add some debug statements to see what is going on.

Without more information about the csp.php script and your environment, it is difficult to provide a more specific solution.