MBS Curl Reading Response Header

Hi to all!

I’m using MBS Curl Plugin to call a remote webservice.
The service, after sending username and password, will return a token, to use in the following calls.

The token is located in the header of the response and I’m not able to read it!
Tried many examples…
by the way:

this is my call:

dim c as new CURLSMBS

dim header() as String
header.Append("Content-Type: application/json; charset=UTF-8")
c.SetOptionHTTPHeader(header)

c.OptionPostFields =egov.user

c.CollectDebugData=true
c.CollectHeaderData=true
c.CollectOutputData=true
c.OptionVerbose = true
c.OptionURL = "https://web18.linksmt.it/services/auth/login"
c.OptionPost = true

'c.OptionSSLVersion = c.kSSLVersionTLSv12
dim e as integer = c.Perform
DebugTextArea.Text = c.DebugData
ResultTextArea.Text = c.OutputData
c.ClearData

this is the response (the token is in DebugTextArea.Text after X-Auth:):

ResultTextArea.Text

{"username":"ncs","authorities":[{"authority":"/mensa/iscritti","ipaCode":"c_a662"},{"authority":"/mensa/posizione-economica","ipaCode":"c_a662"}]}

DebugTextArea.Text

 Trying 93.145.212.20...
Connected to web18.linksmt.it (93.145.212.20) port 443 (#0)
ALPN, offering http/1.1
Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
TLSv1.2 (OUT), TLS header, Certificate Status (22):
TLSv1.2 (OUT), TLS handshake, Client hello (1):
TLSv1.2 (IN), TLS handshake, Server hello (2):
TLSv1.2 (IN), TLS handshake, Certificate (11):
TLSv1.2 (IN), TLS handshake, Server key exchange (12):
TLSv1.2 (IN), TLS handshake, Server finished (14):
TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
TLSv1.2 (OUT), TLS change cipher, Client hello (1):
TLSv1.2 (OUT), TLS handshake, Finished (20):
TLSv1.2 (IN), TLS change cipher, Client hello (1):
TLSv1.2 (IN), TLS handshake, Finished (20):
SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
ALPN, server accepted to use http/1.1
Server certificate:
	 subject: OU=Domain Control Validated; OU=EssentialSSL Wildcard; CN=*.linksmt.it
	 start date: Sep 21 00:00:00 2018 GMT
	 expire date: Nov 19 23:59:59 2020 GMT
	 issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO RSA Domain Validation Secure Server CA
	 SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
POST /services/auth/login HTTP/1.1
Host: web18.linksmt.it
Accept: */*
Content-Type: application/json; charset=UTF-8
Content-Length: 62

upload completely sent off: 62 out of 62 bytes
HTTP/1.1 200 OK
Date: Mon, 30 Mar 2020 16:32:19 GMT
Server: Apache/2.4.41 (Ubuntu)
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: ACL, CANCELUPLOAD, CHECKIN, CHECKOUT, COPY, DELETE, GET, HEAD, LOCK, MKCALENDAR, MKCOL, MOVE, OPTIONS, POST, PROPFIND, PROPPATCH, PUT, REPORT, SEARCH, UNCHECKOUT, UNLOCK, UPDATE, VERSION-CONTROL
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Key, Authorization, X-Auth
Access-Control-Expose-Headers: X-Auth
X-Auth: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJuY3MiLCJpcGFDb2RlIjoiY19hNjYyIiwiaXNFbmFibGVkIjp0cnVlLCJleHAiOjE1ODU1ODc3MzksImlhdCI6MTU4NTU4NTkzOTEwNywiYXV0aG9yaXRpZXMiOnsiL21lbnNhL3Bvc2l6aW9uZS1lY29ub21pY2EiOiJjX2E2NjIiLCIvbWVuc2EvaXNjcml0dGkiOiJjX2E2NjIifX0.JQrlPRJpgF2Im7tChA-pcx8CIBNENeDC-7bvbC2JzHg
Token-Expire: 2020-03-30T19:02:19+0200
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked

Connection #0 to host web18.linksmt.it left intact

And what is in HeaderData property?
You may just split by lines and look for the “X-Auth:” line.

yes, finally I made that way…

//recuperiamo il token
Dim Lines() As String = DebugTextArea.Text.Split(&u0A)
For Each valore As String In Lines
  if  valore.Mid(1,8)="X-Auth: " then
    valore=valore.Mid(9).Trim
    msgbox(valore)
  end if
Next