Skillnad mellan versioner av "Errors:Examples"

Från Vendre Help
Hoppa till: navigering, sök
(Skapade sidan med '== Examples == === Example 1 === ; Request <syntaxhighlight lang="json"> { "query:MinProdukt": { "products": { "filters": { "where": { "id": 183...')
Rad 1: Rad 1:
 
== Examples ==
 
== Examples ==
=== Example 1 ===
+
=== VQL - Invalid attribute and invalid relation ===
 +
The query can return valid data in addition to one or more errors.
 
; Request
 
; Request
<syntaxhighlight lang="json">
+
<pre>
 
{
 
{
 
   "query:MinProdukt": {
 
   "query:MinProdukt": {
Rad 28: Rad 29:
 
   }
 
   }
 
}
 
}
</syntaxhighlight>
+
</pre>
  
 
; Response
 
; Response
<syntaxhighlight lang="json">
+
<pre>
 
{
 
{
 
   "data": {
 
   "data": {
Rad 69: Rad 70:
 
   ]
 
   ]
 
}
 
}
</syntaxhighlight>
+
</pre>
  
=== Example 2 ===
+
=== VQL - Invalid json ===
 
; Request
 
; Request
<syntaxhighlight lang="json">
+
<pre>
 
{
 
{
   "invalid_json": {}
+
   "invalid_json": {
 
}
 
}
</syntaxhighlight>
+
</pre>
  
 
; Response
 
; Response
<syntaxhighlight lang="json">
+
<pre>
 
{
 
{
 
   "errors": [
 
   "errors": [
 
     {
 
     {
 
       "status": "400",
 
       "status": "400",
       "code": "VQL_ERROR_MALFORMED_QUERY",
+
       "code": "VQL_ERROR_MALFORMED_BODY",
 
       "public": false,
 
       "public": false,
 
       "title": "Malformed request body."
 
       "title": "Malformed request body."
Rad 91: Rad 92:
 
   ]
 
   ]
 
}
 
}
</syntaxhighlight>
+
</pre>
  
=== Example 3 ===
+
=== Surface - 403 ===
 
; Request
 
; Request
<syntaxhighlight lang="json">
+
<pre>
 
{
 
{
 
   "route": "surface/1/voucher/value?voucher=2",
 
   "route": "surface/1/voucher/value?voucher=2",
 
   "method": "POST"
 
   "method": "POST"
 
}
 
}
</syntaxhighlight>
+
</pre>
  
 
; Response
 
; Response
<syntaxhighlight lang="json">
+
<pre>
 
{
 
{
 
   "errors": [
 
   "errors": [
Rad 112: Rad 113:
 
   ]
 
   ]
 
}
 
}
</syntaxhighlight>
+
</pre>
  
=== Example 4 ===
+
=== Surface - 403 with title ===
 
; Request
 
; Request
<syntaxhighlight lang="json">
+
<pre>
 
{
 
{
 
   "route": "surface/1/voucher/value?voucher=2",
 
   "route": "surface/1/voucher/value?voucher=2",
 
   "method": "POST"
 
   "method": "POST"
 
}
 
}
</syntaxhighlight>
+
</pre>
  
 
; Response
 
; Response
<syntaxhighlight lang="json">
+
<pre>
 
{
 
{
 
   "errors": [
 
   "errors": [
Rad 135: Rad 136:
 
   ]
 
   ]
 
}
 
}
</syntaxhighlight>
+
</pre>
  
=== Example 5 ===
+
=== Surface - title that can be used ===
 
; Request
 
; Request
<syntaxhighlight lang="json">
+
<pre>
 
{
 
{
 
   "route": "surface/1/bankid/qr-token",
 
   "route": "surface/1/bankid/qr-token",
 
   "method": "GET"
 
   "method": "GET"
 
}
 
}
</syntaxhighlight>
+
</pre>
  
 
; Response
 
; Response
<syntaxhighlight lang="json">
+
<pre>
 
{
 
{
 
   "errors": [
 
   "errors": [
Rad 158: Rad 159:
 
   ]
 
   ]
 
}
 
}
</syntaxhighlight>
+
</pre>

Versionen från 12 juni 2025 kl. 16.40

Examples

VQL - Invalid attribute and invalid relation

The query can return valid data in addition to one or more errors.

Request
{
  "query:MinProdukt": {
    "products": {
      "filters": {
        "where": {
          "id": 183
        },
        "limit": 10
      },
      "fields": [
        "id",
        "name",
        "tax_rate",
        "invalid_attribute",
        {
          "invalidRelation": {
            "fields": [
              "_all"
            ]
          }
        }
      ]
    }
  }
}
Response
{
  "data": {
    "MinProdukt": {
      "products": [
        {
          "id": 183,
          "name": "Clementine Dress",
          "tax_rate": 25
        }
      ]
    }
  },
  "errors": [
    {
      "id": "062b392d-fb87-48bf-a898-54615a5946c0",
      "status": "422",
      "code": "VQL_ERROR_INVALID_ATTRIBUTE",
      "public": true,
      "title": "Invalid attribute requested.",
      "detail": "The requested attribute: invalid_attribute is invalid.",
      "source": {
        "pointer": "/query:MinProdukt/products/fields/3"
      }
    },
    {
      "id": "5fd5445d-f670-42d5-a966-a3d13d218f4c",
      "status": "422",
      "code": "VQL_ERROR_INVALID_RELATION",
      "public": true,
      "title": "Invalid relation requested.",
      "detail": "The requested relation: invalid_relation is invalid.",
      "source": {
        "pointer": "/query:MinProdukt/products/fields/4"
      }
    }
  ]
}

VQL - Invalid json

Request
{
  "invalid_json": {
}
Response
{
  "errors": [
    {
      "status": "400",
      "code": "VQL_ERROR_MALFORMED_BODY",
      "public": false,
      "title": "Malformed request body."
    }
  ]
}

Surface - 403

Request
{
  "route": "surface/1/voucher/value?voucher=2",
  "method": "POST"
}
Response
{
  "errors": [
    {
      "status": "403",
      "code": "VOUCHER_ERROR_8C3D7270"
    }
  ]
}

Surface - 403 with title

Request
{
  "route": "surface/1/voucher/value?voucher=2",
  "method": "POST"
}
Response
{
  "errors": [
    {
      "status": "403",
      "code": "VOUCHER_ERROR_8C3D7270",
      "public": false,
      "title": "Disabled through cright."
    }
  ]
}

Surface - title that can be used

Request
{
  "route": "surface/1/bankid/qr-token",
  "method": "GET"
}
Response
{
  "errors": [
    {
      "status": "422",
      "code": "BANKID_NO_ACTIVE_SESSION",
      "public": true,
      "title": "BankID session not started."
    }
  ]
}