79144869

Date: 2024-10-31 13:17:17
Score: 0.5
Natty:
Report link
public static String getAuthToken(){
        def http = new HTTPBuilder(url + "some/url")   
        http.request (POST) { multipartRequest ->
            MultipartEntityBuilder multipartRequestEntity = new MultipartEntityBuilder()
            String key = 
            multipartRequestEntity.addPart('Username', new StringBody(user))
            multipartRequestEntity.addPart('Password', new StringBody(password))

            multipartRequest.entity = multipartRequestEntity.build()

            response.success = { resp, data ->
                return data['token']
            }
            response.failure = { resp, data ->
                return data
            }
        }
    }

U can perform form filling by using MultipartRequestEntityBuilder

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: lchnkv av