Open2b versione 7.5

urls

urls.resolve

Resolves a site URL and returns the corresponding resources or the URL to which to redirect.

Request

Admin SDK
Admin.api('site.urls.resolve', request, function(response) { … });
HTTP POST
/api/v10/site.urls.resolve
{
  "language" : "en", // language ( ISO code ) (required) - string(2)
  "url" : "books/Isaac-Asimov" // relative URL to resolve (required) - string(1…255)
}

Response

{
  "status" : "ok",
  "resolvedURL" : { // resolved URL (can be null)
    "redirect" : { // redirect (can be null)
      "url" : "/new-releases", // URL, can be relative or absolute 
      "httpStatus" : 301 // HTTP status code, can be 301, 302, 303 o 307 - int
    },
    "resources" : [ { // resources (can be null)
      "type" : "Department", // type, can be "Collection", "Department", "Product", "Producer", "AttributeValue", "Promotion", "Page" or "BlogPost" - string
      "id" : 91 // identifier - int(1…)
    }, {
      "type" : "AttributeValue",
      "id" : 46
    }, … ],
    "canonicalURL" : { // canonical URL (can be null) - string(2) -> string(10…)
      "en" : "https://www.store.com/books/Isaac-Asimov",
      "it" : "https://www.store.com/it/libri/Isaac-Asimov",
      …
    }
  }
}

Errors

Field Type Description
url Malformed '<url>' is not a relative URL
url Malformed URL '<url>' is reserved

urls.reverse

Returns the canonical URL of a page given the resources to which the page refers to. The method reverse implements the inverse function of resolve.

Request

Admin SDK
Admin.api('site.urls.reverse', request, function(response) { … });
HTTP POST
/api/v10/site.urls.reverse
{
  "resources" : [ { // resources (required)
    "id" : 91, // identifier (required) - int(1…)
    "type" : "Department" // type, can be  "Collection", "Department", "Product", "Producer", "AttributeValue", "Promotion", "Page" or "BlogPost" (required) - string
  }, {
    "id" : 46,
    "type" : "AttributeValue"
  }, … ]
}

Response

{
  "status" : "ok",
  "canonicalURL" : { // canonical URL (can be null) - string(2) -> string(10…)
    "en" : "https://www.store.com/books/Isaac-Asimov",
    "it" : "https://www.store.com/it/libri/Isaac-Asimov",
    …
  }
}

Errors

resources Malformed A resource is repeated
resources Malformed Blog posts cannot be combined with other resources
resources Malformed Pages cannot be combined with other resources
resources Malformed Products cannot be combined with other resources
resources Malformed Promotions cannot be combined with other resources
resources Malformed There cannot be more than one collection
resources Malformed There cannot be more than one department
resources Malformed There cannot be more than one producer
resources NotFound Resource <id> of type '<type>' does not exist