API Token vs Personal Access Token
Asked by Miguel P:

I have access to my company's Confluence page (using Confluence cloud). They want me to create an application that communicates with the Confluence API to post content in pages.

I'm following this guide for getting started with the API: [Getting started with Connect (atlassian.com)](https://developer.atlassian.com/cloud/confluence/getting-started-with-connect/)

Issue is I have no idea how to create an API token to communicate with our Confluence. My credentials for logging into my company's confluence aren't my Atlassian account credentials. So I can't just log into the API token page and create one. On the company's Confluence I did find something called Personal Access Tokens, but I'm not sure if they have the same functionality as an API token (not sure if they can be used to communicate with Confluence's REST API).


Answers:
author: Peter Wein
body: Answer is not valid anymore!


author: marc -Collabello--Phase Locked-
body: [@Miguel P](/t5/user/viewprofilepage/user-id/4501150)Connect (the Atlassian app framework) and the "normal" REST API are different things. A connect app needs to be installed from the Atlassian Marketplace.

You can write a program using the REST API, and you don't need the Marketplace for this. For auth with the REST API, you need to log into your Atlassian account and retrieve a token. This token allows you to script the REST API with your access rights.

Another option is to use Oauth.

comments: author: Peter Wein
body: I have the same problem! And I absolutely did not understand your answer [@marc -Collabello--Phase Locked-](https://community.atlassian.com/t5/user/viewprofilepage/user-id/1205132) . Please explain yourself. I have created an atlassian account and I am able to create an "API Token" but how should this help me get into our company's own Jira Server???

There is as far as I know no connection between atlassian domain and our implementation of our company's own JIRA server. So how can I connect with the "Personal Access Token" via rest api. I found an example for c#:

code c#:

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web.Script.Serialization;
using Newtonsoft.Json;


//using System.Net.Http.Json;

namespace JIRA_SDK
{

   public class JiraHelper
   {
      private static HttpClient _client = new HttpClient();
      public static async Task<JiraTicketResponse> CreateTaskTicket(Uri jiraUri, string userName, string apiKey, string projectKey, string summary, string description)
      {
         var authData = System.Text.Encoding.UTF8.GetBytes($"{userName}:{apiKey}");
         var basicAuthentication = Convert.ToBase64String(authData);
         _client.BaseAddress = jiraUri;
         _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", basicAuthentication);
         var data = new
         {
            fields = new
            {
               issuetype = new { id = 10002 /*Task*/ },
               summary = summary,
               project = new { key = projectKey /*Key of your project*/},
               description = new
               {
                  version = 1,
                  type = "doc",
                  content = new[] {
                     new {
                        type = "paragraph",
                        content = new []{
                           new {
                              type = "text",
                              text = description
                           }
                        }
                     }            
                 }
               }
            }
         };
      
         var result = _client.PostAsync("/rest/api/3/issue", new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json")).Result;
         if (result.StatusCode == System.Net.HttpStatusCode.Created)
         {
            string jsonContent = result.Content.ReadAsStringAsync().Result;//<JiraTicketResponse>();
            return JsonConvert.DeserializeObject<JiraTicketResponse>(jsonContent);
         }
         else
            throw new Exception(await result.Content.ReadAsStringAsync());
      }
   }

   public class JiraTicketResponse
   {
      public int Id { get; set; }
      public string Key { get; set; }
      public Uri Self { get; set; }
   }
}
```

Code c# finish. (is there a way to put formatted code in the answer? without reformatting every line?)

derived from this [link](https://learn.microsoft.com/en-us/answers/questions/1167864/jira-using-c?page=1&orderby=helpful&comment=answer-1171476)

But I am getting an "unauthorized" result from my post request! Please help!

My starting page is like this:

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/265922i0584B4460FDA207F/image-size/large?v=v2&px=999 "image.png")

Or is there any supported official library for C#? It should provide a method for token access. I don't need basic auth nor oauth...


author: marc -Collabello--Phase Locked-
body: Hi [@Peter Wein](/t5/user/viewprofilepage/user-id/5161769) ,

It seems you are using Jira server software. The answer I provided is for Confuence cloud.

That means my answer dos not work for Jira server! But the answer works for Confluence cloud.


Tags: cloud

confluence-cloud

token