---
title: Authentication
slug: singleconnect-2-16/authentication
description: Learn how to log in and log out of a server using various programming languages with this comprehensive document. Find code examples in C#, cURL, and JavaScript, including the login request with username and password, and the response with a sessionId. Al
docTags: 
createdAt: 2021-02-24T15:07:14.000Z
---



:::ApiMethodV2
```json
{
  "tab": "examples",
  "url": "http://{{hostname}}/aioc-rest-web/rest/login",
  "name": "Login",
  "method": "POST",
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [],
    "bodyDataParameters": [
      {
        "kind": "required",
        "name": "username",
        "type": "string",
        "description": "admin"
      },
      {
        "kind": "required",
        "name": "password",
        "type": "string",
        "description": "admin"
      }
    ],
    "formDataParameters": []
  },
  "results": {
    "languages": [
      {
        "id": "Dp2IBUzahMSaCWq-HysRF",
        "code": "{\n    \"sessionId\": \"a1b71fc8-da07-4c0a-b582-c17e03f8fbbf\"\n}",
        "language": "200"
      }
    ],
    "selectedLanguageId": "Dp2IBUzahMSaCWq-HysRF"
  },
  "examples": {
    "languages": [
      {
        "id": "iE57sEIMCrEMVhNDz34Jx",
        "code": "var client = new RestClient(\"http://{{hostname}}/aioc-rest-web/rest/login\");\r\nclient.Timeout = -1;\r\nvar request = new RestRequest(Method.POST);\r\nrequest.AddHeader(\"Content-Type\", \"application/json\");\r\nrequest.AddHeader(\"Cookie\", \"NETRIGHT_SESSIONID=a1b71fc8-da07-4c0a-b582-c17e03f8fbbf\");\r\nrequest.AddParameter(\"application/json\", \"{\\\"username\\\":\\\"admin\\\",\\\"password\\\":\\\"admin\\\"}\",  ParameterType.RequestBody);\r\nIRestResponse response = client.Execute(request);\r\nConsole.WriteLine(response.Content);",
        "language": "csharp"
      },
      {
        "id": "zG7cKs2fHAXCukbBxr0z0",
        "code": "curl --location --request POST 'http://{{hostname}}/aioc-rest-web/rest/login' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Cookie: NETRIGHT_SESSIONID=a1b71fc8-da07-4c0a-b582-c17e03f8fbbf' \\\r\n--data-raw '{\"username\":\"admin\",\"password\":\"admin\"}'",
        "language": "curl"
      },
      {
        "id": "5mfyrHDZZNB9qlL5yM1a4",
        "code": "var settings = {\n  \"url\": \"http://{{hostname}}/aioc-rest-web/rest/login\",\n  \"method\": \"POST\",\n  \"timeout\": 0,\n  \"headers\": {\n    \"Content-Type\": \"application/json\"\n  },\n  \"data\": JSON.stringify({\"username\":\"admin\",\"password\":\"admin\"}),\n};\n\n$.ajax(settings).done(function (response) {\n  console.log(response);\n});",
        "language": "javascript"
      }
    ],
    "selectedLanguageId": "iE57sEIMCrEMVhNDz34Jx"
  },
  "description": " ",
  "currentNewParameter": {
    "label": "Form Parameter",
    "value": "formDataParameters"
  }
}
```
:::





:::ApiMethodV2
```json
{
  "tab": "examples",
  "url": "http://{{hostname}}/aioc-rest-web/rest/logout",
  "name": "Logout",
  "method": "POST",
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [],
    "bodyDataParameters": [
      {
        "kind": "required",
        "name": "id",
        "type": "string",
        "description": "ID of the cake to get"
      }
    ],
    "formDataParameters": []
  },
  "results": {
    "languages": [
      {
        "id": "yxMVSHuEolq5ZLK7o852M",
        "code": "",
        "language": "200"
      }
    ],
    "selectedLanguageId": "yxMVSHuEolq5ZLK7o852M"
  },
  "examples": {
    "languages": [
      {
        "id": "wbbT7pU3hi1iyITuwBd3t",
        "code": "var client = new RestClient(\"http://{{hostname}}/aioc-rest-web/rest/logout\");\r\nclient.Timeout = -1;\r\nvar request = new RestRequest(Method.POST);\r\nrequest.AddHeader(\"Content-Type\", \"application/json\");\r\nrequest.AddParameter(\"application/json\", \"\",  ParameterType.RequestBody);\r\nIRestResponse response = client.Execute(request);\r\nConsole.WriteLine(response.Content);",
        "language": "csharp"
      },
      {
        "id": "qDaFJlRWSYZM3pbQQ-R0Z",
        "code": "curl --location -g --request POST 'http://{{hostname}}/aioc-rest-web/rest/logout' \\\n--header 'Content-Type: application/json' \\\n--data-raw ''",
        "language": "curl"
      },
      {
        "id": "ByhBAwsbDVn_8L1-g70Gv",
        "code": "var settings = {\r\n  \"url\": \"http://{{hostname}}/aioc-rest-web/rest/logout\",\r\n  \"method\": \"POST\",\r\n  \"timeout\": 0,\r\n  \"headers\": {\r\n    \"Content-Type\": \"application/json\"\r\n  },\r\n};\r\n\r\n$.ajax(settings).done(function (response) {\r\n  console.log(response);\r\n});",
        "language": "javascript"
      }
    ],
    "selectedLanguageId": "wbbT7pU3hi1iyITuwBd3t"
  },
  "description": " ",
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  }
}
```
:::



