Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Create an issue with excel vba and XSRF check failed

Geo Zhang March 15, 2017

I am trying to use excel vba to create an issue thru Rest API, but it is always failed. The code I am using is as follows:

Public Function JiraUpdateTicketA(JsonUpdate As String, issueKey As String) As String
Dim JiraService As New MSXML2.XMLHTTP60
Dim json As Object

usernamep = UserPassBase64
With JiraService
.Open "POST", GetUrl + "/rest/api/2/issue/", False
.SetRequestHeader "Content-Type", "application/json"
.SetRequestHeader "Accept", "application/json"
.SetRequestHeader "Authorization", "Basic " & usernamep
.Send JsonUpdate
End With
End Function

And the JasonUpdate data I posted is as follows:

{"fields":{"project":{"key":"AUTODFIRSE"},"issuetype":{"name":"Bug"},{"summary":"RDETST_AutoCreation"},{"description":"Start"},"priority":{"id":"3"},"versions":[{"id":"104602"} ],"components":[{"id":"29300"} ]}}

Does anyone know what the issue it is?

JIRA version I used is v6.4.13.

Any help is appreciated!

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 16, 2017

What error are you getting?

Geo Zhang March 16, 2017

Sorry, the error is in the title "XSRF check failed"

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 16, 2017

No, that's a generic headline, not the error.

Consider this case:  "I want to play with penguins".  Error message: "you can't".   Accurate, but useless.  Because the real error is missing. 

Please tell us what the error message is.

Geo Zhang March 18, 2017

Sorry for that, from excel vba I only print the returned text,not the whole http response. And I have some try with other comments in other thread and it works now for me. What I need to do is to add a "original" in request header like this; SetRequestHeader "Origin", "http://jira.xxx.xxx/". But I still do not know why it is. I am not sure if this should be comments in the documentation. Thanks!~

TAGS
AUG Leaders

Atlassian Community Events