1

I am trying to connect a REST API to the "Find An Apprenticeship" web service.

I am trying to do this via Salesforce's "External Service". I have set up the "Named Credential" Named Credentials and now trying to put the "Swagger"/"Open API" in. But I get this error which I can't find anywhere. External Service

This is the JSON Code:

{
  "swagger": "2.0",
  "info": {
    "title": "Manage vacancies API (Sandbox)",
    "version": "1.0",
    "description": "Manage vacancies API (Sandbox)"
  },
  "host": "apis.apprenticeships.sfa.bis.gov.uk",
  "basePath": "/manage-vacancies-sandbox",
  "schemes": [
    "https"
  ],
  "securityDefinitions": {
    "apiKeyHeader": {
      "type": "apiKey",
      "name": "Ocp-Apim-Subscription-Key",
      "in": "header"
    },
    "apiKeyQuery": {
      "type": "apiKey",
      "name": "subscription-key",
      "in": "query"
    }
  },
  "security": [
    {
      "apiKeyHeader": []
    },
    {
      "apiKeyQuery": []
    }
  ],
  "x-servers": [
    {
      "url": "https://apis.apprenticeships.sfa.bis.gov.uk"
    },
    {
      "url": "https://apis.apprenticeships.education.gov.uk"
    }
  ],
  "paths": {
    "/v1/apprenticeships": {
      "post": {
        "description": "The apprenticeship operation creates an apprenticeship vacancy using the specified values.\r\n\r\n#### Restricted values ####\r\n\r\nThese fields will only accept specific values as listed below:\r\n* ApplicationMethod\r\n    - Online\r\n    - Offline\r\n* LocationType\r\n    - OtherLocation\r\n    - EmployerLocation\r\n    - Nationwide\r\n* DurationType\r\n    - Weeks\r\n    - Months\r\n    - Years\r\n* WageType\r\n    - CustomWageFixed\r\n    - CustomWageRange\r\n    - NationalMinimumWage\r\n    - ApprenticeshipMinimumWage\r\n    - Unwaged\r\n    - CompetitiveSalary\r\n    - ToBeSpecified\r\n* WageUnit\r\n    - NotApplicable\r\n    - Weekly\r\n    - Monthly\r\n    - Annually\r\n* TrainingType\r\n    - Framework\r\n    - Standard\r\n\r\n#### Validation rules ####\r\n\r\nWhen creating a vacancy the following rules must be considered. \r\n1. All values are required to be populated except in the following cases:\r\n\r\n* For all vacancies these values are optional\r\n    - ContactName\r\n    - ContactEmail\r\n    - ContactNumber\r\n    - ThingsToConsider\r\n\r\n* For an Online vacancy\r\n    - SupplementaryQuestion1 and SupplementaryQuestion2 are optional\r\n    - ExternalApplicationUrl and ExternalApplicationInstructions must be empty\r\n\r\n* For an Offline vacancy\r\n    - ExternalApplicationInstructions is optional\r\n    - SupplementaryQuestion1 and SupplementaryQuestion2 must be empty\r\n\r\n* When LocationType is EmployerLocation or Nationwide \r\n    - Location is not required.\r\n\r\n* When LocationType is OtherLocation \r\n    - Only Address1, Town and Postcode are required\r\n    - All other address fields are optional\r\n\r\n* When WageType is CustomWageFixed\r\n    - WageTypeReason must be empty\r\n    - WageUnit must be a value other than NotApplicable\r\n    - MinWage and MaxWage must be empty\r\n    - FixedWage must be greater than or equal to the Apprenticeship minimum wage \r\n\r\n* When WageType is CustomWageRange\r\n    - WageTypeReason must be empty\r\n    - WageUnit must be a value other than NotApplicable\r\n    - MinWage must be greater than or equal to the Apprenticeship minimum wage \r\n    - MaxWage must be greater than MinWage\r\n    - FixedWage must be empty\r\n\r\n* When WageType is NationalMinimumWage or ApprenticeshipMinimumWage\r\n    - MinWage, MaxWage, FixedWage and WageTypeReason must be empty\r\n    - WageUnit must be NotApplicable\r\n\r\n* When WageType is Unwaged, CompetitiveSalary or ToBeSpecified\r\n    - FixedWage, MinWage and MaxWage must be empty\r\n    - WageUnit must be NotApplicable\r\n\r\n* When TrainingType is Framework\r\n    - TrainingCode should be in format ###-##-##\r\n\r\n* When TrainingType is Standard\r\n    - TrainingCode should be a numeric value no greater than 9999\r\n\r\n* Text fields will take a maximum of 4,000 characters except for the following\r\n    - Title = 100\r\n    - ShortDescription = 350\r\n    - ContactName = 100\r\n    - ContactEmail = 100\r\n    - AddressLine = 300\r\n    - Town = 100\r\n    - WageTypeReason = 240\r\n    - WorkingWeek = 250\r\n\r\n* Additional rules\r\n    - Title must include the word ***apprentice***\r\n    - HoursPerWeek must be between 16 and 48 inclusive\r\n    - ExpectedDuration must be a minimum of 1 year, 12 months or 52 weeks depending on the value of DurationType selected\r\n    - NumberOfPositions must not exceed 5,000\r\n\r\n#### Error codes ####\r\n\r\nThe following error codes may be returned when calling this operation if any of the vacancy values \r\nspecified fail validation:\r\n\r\n| Error code  | Explanation                                 |\r\n| ----------- | ------------------------------------------- |\r\n| 31000       | Invalid Request body                        |\r\n| 31001       | Invalid Title                               |\r\n| 31002       | Invalid Short description                   |\r\n| 31003       | Invalid Long description                    |\r\n| 31004       | Invalid Application closing date            |\r\n| 31005       | Invalid Expected start date                 |\r\n| 31006       | Invalid Working week                        |\r\n| 31007       | Invalid Hours per week                      |\r\n| 31008       | Invalid Wage type                           |\r\n| 31009       | Invalid Wage type reason                    |\r\n| 31010       | Invalid Wage unit                           |\r\n| 31011       | Invalid Fixed wage                          |\r\n| 31012       | Invalid Min wage                            |\r\n| 31013       | Invalid Max wage                            |\r\n| 31014       | Invalid Expected duration                   |\r\n| 31015       | Invalid Duration type                       |\r\n| 31016       | Invalid Location type                       |\r\n| 31017       | Invalid Location Address line 1             |\r\n| 31018       | Invalid Location Address line 2             |\r\n| 31019       | Invalid Location Address line 3             |\r\n| 31020       | Invalid Location Address line 4             |\r\n| 31021       | Invalid Location Address line 5             |\r\n| 31022       | Invalid Location Town                       |\r\n| 31023       | Invalid Location Postcode                   |\r\n| 31024       | Invalid Number of positions                 |\r\n| 31025       | Invalid Provider's Ukprn                    |\r\n| 31026       | Invalid Employer's Edsurn                   |\r\n| 31027       | Invalid Provider site's Edsurn              |\r\n| 31028       | Invalid Contact Name                        |\r\n| 31029       | Invalid Contact Email                       |\r\n| 31030       | Invalid Contact Number                      |\r\n| 31031       | Invalid Training Type                       |\r\n| 31032       | Invalid Training Code                       |\r\n| 31033       | Invalid Desired skills                      |\r\n| 31034       | Invalid Desired personal qualities          |\r\n| 31035       | Invalid Desired qualifications              |\r\n| 31036       | Invalid Future prospects                    |\r\n| 31037       | Invalid Things to consider                  |\r\n| 31038       | Invalid Training to be provided             |\r\n| 31039       | Invalid Application method                  |\r\n| 31040       | Invalid Supplementary question 1            |\r\n| 31041       | Invalid Supplementary question 2            |\r\n| 31042       | Invalid External application url            |\r\n| 31043       | Invalid External Application Instructions   |\r\n| 31044       | Invalid Is Employer Disability Confident    |\r\n| 31045       | Invalid Location Additional Information     |\r\n| 31046       | Invalid Employer Description                |\r\n| 31047       | Invalid Employer Website Url                |",
        "operationId": "CreateApprenticeshipVacancy",
        "summary": "CreateApprenticeshipVacancy",
        "tags": [
          "Apprenticeships"
        ],
        "parameters": [
          {
            "name": "createApprenticeshipParameters",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/CreateApprenticeshipParameters"
            }
          }
        ],
        "consumes": [
          "application/json",
          "text/json",
          "application/xml",
          "text/xml",
          "application/x-www-form-urlencoded"
        ],
        "produces": [
          "application/json",
          "text/json",
          "application/xml",
          "text/xml"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/CreateApprenticeshipResponse"
            }
          },
          "400": {
            "description": "Failed request validation",
            "schema": {
              "$ref": "#/definitions/BadRequestContent"
            }
          },
          "401": {
            "description": "Invalid provider ukprn",
            "schema": {
              "$ref": "#/definitions/StringContent"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "CreateApprenticeshipParameters": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string"
        },
        "shortDescription": {
          "type": "string"
        },
        "longDescription": {
          "type": "string"
        },
        "desiredSkills": {
          "type": "string"
        },
        "desiredPersonalQualities": {
          "type": "string"
        },
        "desiredQualifications": {
          "type": "string"
        },
        "futureProspects": {
          "type": "string"
        },
        "thingsToConsider": {
          "type": "string"
        },
        "trainingToBeProvided": {
          "type": "string"
        },
        "applicationMethod": {
          "enum": [
            "Online",
            "Offline"
          ],
          "type": "string"
        },
        "supplementaryQuestion1": {
          "type": "string"
        },
        "supplementaryQuestion2": {
          "type": "string"
        },
        "externalApplicationUrl": {
          "type": "string"
        },
        "externalApplicationInstructions": {
          "type": "string"
        },
        "expectedDuration": {
          "format": "int32",
          "type": "integer"
        },
        "durationType": {
          "enum": [
            "Weeks",
            "Months",
            "Years"
          ],
          "type": "string"
        },
        "applicationClosingDate": {
          "format": "date-time",
          "type": "string"
        },
        "expectedStartDate": {
          "format": "date-time",
          "type": "string"
        },
        "workingWeek": {
          "type": "string"
        },
        "hoursPerWeek": {
          "format": "double",
          "type": "number"
        },
        "wageType": {
          "enum": [
            "CustomWageFixed",
            "CustomWageRange",
            "NationalMinimumWage",
            "ApprenticeshipMinimumWage",
            "Unwaged",
            "CompetitiveSalary",
            "ToBeSpecified"
          ],
          "type": "string"
        },
        "wageTypeReason": {
          "type": "string"
        },
        "wageUnit": {
          "enum": [
            "NotApplicable",
            "Weekly",
            "Monthly",
            "Annually"
          ],
          "type": "string"
        },
        "minWage": {
          "format": "double",
          "type": "number"
        },
        "maxWage": {
          "format": "double",
          "type": "number"
        },
        "fixedWage": {
          "format": "double",
          "type": "number"
        },
        "locationType": {
          "enum": [
            "OtherLocation",
            "EmployerLocation",
            "Nationwide"
          ],
          "type": "string"
        },
        "location": {
          "$ref": "#/definitions/Location"
        },
        "numberOfPositions": {
          "format": "int32",
          "type": "integer"
        },
        "employerEdsUrn": {
          "format": "int32",
          "type": "integer"
        },
        "providerSiteEdsUrn": {
          "format": "int32",
          "type": "integer"
        },
        "contactName": {
          "type": "string"
        },
        "contactEmail": {
          "type": "string"
        },
        "contactNumber": {
          "type": "string"
        },
        "trainingType": {
          "enum": [
            "Framework",
            "Standard"
          ],
          "type": "string"
        },
        "trainingCode": {
          "type": "string"
        },
        "isEmployerDisabilityConfident": {
          "type": "boolean"
        },
        "employerWebsiteUrl": {
          "type": "string"
        },
        "employerDescription": {
          "type": "string"
        }
      }
    },
    "Location": {
      "type": "object",
      "properties": {
        "addressLine1": {
          "type": "string"
        },
        "addressLine2": {
          "type": "string"
        },
        "addressLine3": {
          "type": "string"
        },
        "addressLine4": {
          "type": "string"
        },
        "addressLine5": {
          "type": "string"
        },
        "postcode": {
          "type": "string"
        },
        "town": {
          "type": "string"
        },
        "additionalInformation": {
          "type": "string"
        }
      }
    },
    "CreateApprenticeshipResponse": {
      "type": "object",
      "properties": {
        "vacancyReferenceNumber": {
          "format": "int32",
          "type": "integer"
        }
      }
    },
    "BadRequestContent": {
      "type": "object",
      "properties": {
        "requestErrors": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/BadRequestError"
          }
        }
      }
    },
    "BadRequestError": {
      "type": "object",
      "properties": {
        "errorCode": {
          "type": "string"
        },
        "errorMessage": {
          "type": "string"
        }
      }
    },
    "StringContent": {
      "type": "object",
      "properties": {
        "headers": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/KeyValuePair[String,IEnumerable[String]]"
          },
          "readOnly": true
        }
      }
    },
    "KeyValuePair[String,IEnumerable[String]]": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string",
          "readOnly": true
        },
        "value": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "readOnly": true
        }
      }
    }
  },
  "tags": []
}

Any help on what this error could relate to would be much appreciated.

Many thanks. (I'm also in a sandbox if that makes a difference)

  • 1
    are you able to even save a simple schema? normally you would get an Invalid Schema error at that point, not seen that before – Phil Hawthorn Jun 26 at 14:45
  • 2
    actually, just tried to save your schema and i get the same error - try deleting chunks until by a process of elimination you find the issue – Phil Hawthorn Jun 26 at 14:46
  • Okay I'll give that a go thankyou Phil – Daniel Bleasdale Jun 28 at 14:18
1

As I answered here, it appears to be an issue with the description. Fixing the description part should help solve the error and take you to the next step.

{
  "swagger": "2.0",
  "info": {
    "title": "Manage vacancies API (Sandbox)",
    "version": "1.0",
    "description": "Manage vacancies API (Sandbox)"
  },
  "host": "apis.apprenticeships.sfa.bis.gov.uk",
  "basePath": "/manage-vacancies-sandbox",
  "schemes": [
    "https"
  ],
  "securityDefinitions": {
    "apiKeyHeader": {
      "type": "apiKey",
      "name": "Ocp-Apim-Subscription-Key",
      "in": "header"
    },
    "apiKeyQuery": {
      "type": "apiKey",
      "name": "subscription-key",
      "in": "query"
    }
  },
  "security": [
    {
      "apiKeyHeader": []
    },
    {
      "apiKeyQuery": []
    }
  ],
  "x-servers": [
    {
      "url": "https://apis.apprenticeships.sfa.bis.gov.uk"
    },
    {
      "url": "https://apis.apprenticeships.education.gov.uk"
    }
  ],
  "paths": {
    "/v1/apprenticeships": {
      "post": {
        "description": "",
        "operationId": "CreateApprenticeshipVacancy",
        "summary": "CreateApprenticeshipVacancy",
        "tags": [
          "Apprenticeships"
        ],
        "parameters": [
          {
            "name": "createApprenticeshipParameters",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/CreateApprenticeshipParameters"
            }
          }
        ],
        "consumes": [
          "application/json",
          "text/json",
          "application/xml",
          "text/xml",
          "application/x-www-form-urlencoded"
        ],
        "produces": [
          "application/json",
          "text/json",
          "application/xml",
          "text/xml"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/CreateApprenticeshipResponse"
            }
          },
          "400": {
            "description": "Failed request validation",
            "schema": {
              "$ref": "#/definitions/BadRequestContent"
            }
          },
          "401": {
            "description": "Invalid provider ukprn",
            "schema": {
              "$ref": "#/definitions/StringContent"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "CreateApprenticeshipParameters": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string"
        },
        "shortDescription": {
          "type": "string"
        },
        "longDescription": {
          "type": "string"
        },
        "desiredSkills": {
          "type": "string"
        },
        "desiredPersonalQualities": {
          "type": "string"
        },
        "desiredQualifications": {
          "type": "string"
        },
        "futureProspects": {
          "type": "string"
        },
        "thingsToConsider": {
          "type": "string"
        },
        "trainingToBeProvided": {
          "type": "string"
        },
        "applicationMethod": {
          "enum": [
            "Online",
            "Offline"
          ],
          "type": "string"
        },
        "supplementaryQuestion1": {
          "type": "string"
        },
        "supplementaryQuestion2": {
          "type": "string"
        },
        "externalApplicationUrl": {
          "type": "string"
        },
        "externalApplicationInstructions": {
          "type": "string"
        },
        "expectedDuration": {
          "format": "int32",
          "type": "integer"
        },
        "durationType": {
          "enum": [
            "Weeks",
            "Months",
            "Years"
          ],
          "type": "string"
        },
        "applicationClosingDate": {
          "format": "date-time",
          "type": "string"
        },
        "expectedStartDate": {
          "format": "date-time",
          "type": "string"
        },
        "workingWeek": {
          "type": "string"
        },
        "hoursPerWeek": {
          "format": "double",
          "type": "number"
        },
        "wageType": {
          "enum": [
            "CustomWageFixed",
            "CustomWageRange",
            "NationalMinimumWage",
            "ApprenticeshipMinimumWage",
            "Unwaged",
            "CompetitiveSalary",
            "ToBeSpecified"
          ],
          "type": "string"
        },
        "wageTypeReason": {
          "type": "string"
        },
        "wageUnit": {
          "enum": [
            "NotApplicable",
            "Weekly",
            "Monthly",
            "Annually"
          ],
          "type": "string"
        },
        "minWage": {
          "format": "double",
          "type": "number"
        },
        "maxWage": {
          "format": "double",
          "type": "number"
        },
        "fixedWage": {
          "format": "double",
          "type": "number"
        },
        "locationType": {
          "enum": [
            "OtherLocation",
            "EmployerLocation",
            "Nationwide"
          ],
          "type": "string"
        },
        "location": {
          "$ref": "#/definitions/Location"
        },
        "numberOfPositions": {
          "format": "int32",
          "type": "integer"
        },
        "employerEdsUrn": {
          "format": "int32",
          "type": "integer"
        },
        "providerSiteEdsUrn": {
          "format": "int32",
          "type": "integer"
        },
        "contactName": {
          "type": "string"
        },
        "contactEmail": {
          "type": "string"
        },
        "contactNumber": {
          "type": "string"
        },
        "trainingType": {
          "enum": [
            "Framework",
            "Standard"
          ],
          "type": "string"
        },
        "trainingCode": {
          "type": "string"
        },
        "isEmployerDisabilityConfident": {
          "type": "boolean"
        },
        "employerWebsiteUrl": {
          "type": "string"
        },
        "employerDescription": {
          "type": "string"
        }
      }
    },
    "Location": {
      "type": "object",
      "properties": {
        "addressLine1": {
          "type": "string"
        },
        "addressLine2": {
          "type": "string"
        },
        "addressLine3": {
          "type": "string"
        },
        "addressLine4": {
          "type": "string"
        },
        "addressLine5": {
          "type": "string"
        },
        "postcode": {
          "type": "string"
        },
        "town": {
          "type": "string"
        },
        "additionalInformation": {
          "type": "string"
        }
      }
    },
    "CreateApprenticeshipResponse": {
      "type": "object",
      "properties": {
        "vacancyReferenceNumber": {
          "format": "int32",
          "type": "integer"
        }
      }
    },
    "BadRequestContent": {
      "type": "object",
      "properties": {
        "requestErrors": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/BadRequestError"
          }
        }
      }
    },
    "BadRequestError": {
      "type": "object",
      "properties": {
        "errorCode": {
          "type": "string"
        },
        "errorMessage": {
          "type": "string"
        }
      }
    },
    "StringContent": {
      "type": "object",
      "properties": {
        "headers": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/KeyValuePair[String,IEnumerable[String]]"
          },
          "readOnly": true
        }
      }
    },
    "KeyValuePair[String,IEnumerable[String]]": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string",
          "readOnly": true
        },
        "value": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "readOnly": true
        }
      }
    }
  },
  "tags": []
} 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.