2

I am trying to use $ref from URL & validating json data using NewtonSoft.Json.Schema.

  1. MainSchema.json

    {
        "$schema": "http://json-schema.org/draft-04/schema#",
        "type": "object",
        "properties": {
            "Data": { "$ref": "http://localhost:49735/api/schema/sample" },
        },
        "required": [ "Data" ]
    }
    
  2. SubSchema.json

    {
       "$schema": "http://json-schema.org/draft-04/schema#",
        "type": "object",
        "properties": 
        {
            "Data": 
            {
                "type": "array",
                "items": 
                [
                    {
                        "type": "array",
                        "items": 
                        [
                            {
                                "id": "id1",
                                "type": "string",
                            },
                            {
                                "id": "id2",
                                "type": "number"
                            }
                        ]
                    }
                ]
            }
        }
    }
    

I have created one sample web api application for downloading subschema as json. URL is reffered in main schema http://localhost:49735/api/Schema/Sample The api is developed with No Authentication Mode. I am using NewtonSoft JSON Schema for validation json data. but while resolving json schema it is throwing exception.

"The remote server returned an error: (401) Unauthorized."
Jcl
  • 27,696
  • 5
  • 61
  • 92
NitinK
  • 103
  • 1
  • 7
  • Try to copy the $ref uri into the browser a test the response with the network tool in the web developer tools. Or use `curl`. If there is a 401 response, the error is in your server configuration. – Trendfischer Jan 19 '16 at 18:24
  • from browser it works without any issue. seems like it is just because is unable to use n/w proxy – NitinK Jan 20 '16 at 10:24

1 Answers1

0

It may be a proxy issue on your local network. You could try configuring .NET to use your computer's configured proxy - How to authenticate against a proxy when using the HttpClient class?

Community
  • 1
  • 1
James Newton-King
  • 48,174
  • 24
  • 109
  • 130