c# creat portal user

hi,

i would like to import our it-emails from user via a windows service directly into jira. so far so good. the windows service is working fine.

 

from the licence model: jira differenciats between full user (needs a licence) and portal user (free of licence). my problem is that i would like to create via c# protal-user for the user which are reporting a case, but do not have / need a full licence.

i've found in the sdk so far only the class JiraUser. but it creats me "full-licenced-users".

 

has anyone an idea how to manage this?

 

thanks.

 

br, andre

2 answers

1 accepted

hi @all,

finally i could manage it. my code was fine as well as the data in "theory". json-checker said data was fine. but not for jira.

in the mentioned link to jira-REST-api-customer, jira is presenting an example how json should look like to create a customer:

{"displayName": "string","email": "string","fullName": "string"}

in my IDE i got all the time as an answer to my POST-request "StatusCode: 400, Bad request", but not more.

I heared in a tutorial about the tool POSTMAN, where you can create JSON request to any api. very nice. here i finally got a usable answer >>> "you cannot use displayName and fullName at the same time"

reducing my JSON-data to {"displayName": "string","email": "string"} made my code working.

 

thanks again to the makers of POSTMAN, you saved my day. :)

 

br, andre

 

0 vote
Maarten Cautreels Community Champion May 05, 2017

Hi André,

Luckily you can since they've recently resolved this suggestion: JSDCLOUD-3398.

There's an API especially for this task: https://developer.atlassian.com/cloud/jira/service-desk/rest/#api-customer-post

Hope this helps,

Maarten

thanks fo you quick answer. i'll try it asap. but i never used REST before. it might get a bit tricky for me. ;)

do you know, if they will implement this functionality also in the .net-sdk

 

br, andre

hi, i managed it so far to get users via webRequest/JSON. but when i try to create a user, i get always as response "StatusCode:400 - Bad Request". the new user is defenetly not in the database. but the response does not contain a helpful advice. below my relevant c# code - any idea what i#m doing wrong?

thanks.

br, andre

 

client.BaseAddress = new Uri(url_BaseAddress);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Add("Authorization", " Basic " + base64EncodedCredentials);
client.DefaultRequestHeaders.Add("Accept", "application/json");

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url_Customer_Create);

jsonStr = JsonConvert.SerializeObject(customer);//json string checked via webtool > is OK

request.Content = new StringContent(jsonStr, Encoding.ASCII, "application/json");

using (HttpResponseMessage response = await client.SendAsync(request))
{
if (response.IsSuccessStatusCode)
{
      //some more code...

}
}

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,329 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot