cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
kazssym
Level: Powered On

Parse JSON content whose type is not application/json, how?

I'm trying to parse JSON content whose type is not application/json with a Parse JSON step but I only got errors.  Is there any way to process such content as application/json?

For your information, the content type really is application/csp-report.

1 ACCEPTED SOLUTION

Accepted Solutions
kazssym
Level: Powered On

Re: Parse JSON content whose type is not application/json, how?

FYI, I finally solved this issue by passing "@json(string(triggerBody()))" to Parse JSON.

View solution in original post

5 REPLIES 5
Community Support Team
Community Support Team

Re: Parse JSON content whose type is not application/json, how?

Hi @kazssym,

 

Would you please share the error message here?

What is the schema you have defined under the Parse JSON action?

Have you tried the Use sample payload button?

Parse JSON messages

I am not very familar with that part.

Maybe Staff @masisley could help on this topic.

Regards,

Michael

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
kazssym
Level: Powered On

Re: Parse JSON content whose type is not application/json, how?

Every run stopped with the following error:

BadRequest. The property 'content' must be of type JSON in the 'ParseJson' action inputs, but was of type 'application/csp-report'.

 

The JSON schema I use is this one:

{
  "$schema": "http://json-schema.org/draft-04/schema",
  "title": "JSON Schema for Content Security Policy (Level 2) violation reports",
  "description": "https://www.w3.org/TR/CSP2/#violation-reports",
  "type": "object",
  "required": [
    "csp-report"
  ],
  "properties": {
    "csp-report": {
      "type": "object",
      "properties": {
        "blocked-uri": {
          "type": "string",
          "description": "The originally requested URL of the resource that was prevented from loading, stripped for reporting, or the empty string if the resource has no URL (inline script and inline style, for example)."
        },
        "document-uri": {
          "type": "string",
          "description": "The address of the protected resource, stripped for reporting."
        },
        "effective-directive": {
          "type": "string",
          "description": "The name of the policy directive that was violated. This will contain the directive whose enforcement triggered the violation (e.g. \"script-src\") even if that directive does not explicitly appear in the policy, but is implicitly activated via the default-src directive."
        },
        "original-policy": {
          "type": "string",
          "description": "The original policy, as received by the user agent."
        },
        "referrer": {
          "type": "string",
          "description": "The referrer attribute of the protected resource, or the empty string if the protected resource has no referrer."
        },
        "status-code": {
          "type": "number",
          "description": "The status-code of the HTTP response that contained the protected resource, if the protected resource was obtained over HTTP. Otherwise, the number 0."
        },
        "violated-directive": {
          "type": "string",
          "description": "The policy directive that was violated, as it appears in the policy. This will contain the default-src directive in the case of violations caused by falling back to the default sources when enforcing a directive."
        },
        "source-file": {
          "type": "string",
          "description": "The URL of the resource where the violation occurred, stripped for reporting."
        },
        "line-number": {
          "type": "number",
          "description": "The line number in source-file on which the violation occurred."
        },
        "column-number": {
          "type": "number",
          "description": "The column number in source-file on which the violation occurred."
        }
      }
    }
  },
  "additionalProperties": false
}

kazssym
Level: Powered On

Re: Parse JSON content whose type is not application/json, how?

FYI, I finally solved this issue by passing "@json(string(triggerBody()))" to Parse JSON.

View solution in original post

Anonymous
Not applicable

Re: Parse JSON content whose type is not application/json, how?

Where you passed it?

kazssym
Level: Powered On

Re: Parse JSON content whose type is not application/json, how?

I've done as this.

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,878)