Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NTLM Authentication in groovy (-> Sharepoint-API) #92

Open
schneich opened this issue Jan 27, 2022 · 0 comments
Open

NTLM Authentication in groovy (-> Sharepoint-API) #92

schneich opened this issue Jan 27, 2022 · 0 comments

Comments

@schneich
Copy link

schneich commented Jan 27, 2022

Hi,
I am trying to call a Sharepoint REST-API out of a Jira-Groovy-environment. Unfortunately, I am struggling with the authentication. How do a I have to set up my code, so that NTLM authentication is used, when addressing the sharepoint REST API?

Any help or link to the right documentation is very much appreciated.

My current code, but it results in a 401 response.

import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
import groovyx.net.http.ContentType
import static groovyx.net.http.Method.*
import groovy.json.JsonSlurper
import net.sf.json.groovy.JsonSlurper
import groovyx.net.http.Method

def http = new HTTPBuilder('http://base.url')

http.request(POST, JSON) {
   requestContentType = ContentType.JSON
   headers."Accept-Encoding" = "gzip, deflate, br"
   headers."Accept" = "application/json;odata=verbose"
   headers."Content-Type" = "application/json;odata=verbose"
   headers."Connection" = "keep-alive"


   body = [username: 'user', password: 'password']

      response.success = { resp, JSON ->

         return JSON

      }

      response.failure = { resp ->
         return "Request failed with status ${resp.status}"

      }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant