Curlsmbs basic authentication

Hi!

I’m trying to use a basic authentication with CURLSMBS plugin (from 2017),

tried

  dim c as new CURLSMBS
  
  dim header() as String
  header.Append("Content-Type: application/json; charset=UTF-8")
 
  c.SetOptionHTTPHeader(header)
  c.CollectDebugData=true
  c.CollectHeaderData=true
  c.CollectOutputData=true
  c.OptionVerbose = true
  c.OptionHTTPAuth = 1
  c.OptionUsername = "ncs"
  c.OptionPassword = "pwd"

I get
{“DataServiceFault”:{“current_params”:“{}”,“source_data_service”:{“data_service_name”:“PagamentiScolasticiDataService”,“description”:“N/A”,“location”:“/PagamentiScolasticiDataService.dbs”,“default_namespace”:“http://ws.wso2.org/dataservice"},“ds_code”:“INCOMPATIBLE_PARAMETERS_ERROR”,“current_request_name”:"_getgetpagamentimensa”}}

tried also c.OptionUsername = "ncs:pwd"
I get
unknown

what’s wrong?

The service has responded to your request indicating you have the parameters wrong. We’d need the documentation from the service to know how to correctly pass the parameters.

1 Like

I would set HTTPAuth to 14 or 15 to allow basically all ways.

For basic authentication, the plugin internally builds username and password with double colon to make the authenticate header.
If you put password in the user name, that can’t work well.

Please check documentation on how they do it.
Maybe there is already sample code for curl in command line to php available?

Hi, this is what I do with postman, it works, I need to do the same basic auth from CURLSMBS

I Think should be correct c.OptionUsername = "ncs:pwd"

The -u you see there was an older option UsrPwd, which had both.
Nowadays we have two options, one for username and one for password and CURL does the : automatically.

The thing is the error message said the parameters are incorrect, not the authentication. In your original post the current_params key in the response was empty. I suspect it’s something else about the request that’s malformed.

Update: You can test what the request looks like when it reaches the server with a service like webhook.site. Compare both a Postman and CURLSMBS request and note the differences.

Tried this also…

Do you like to post here or send me a test project to review?

Hi Christian!

I can send the project but you cannot test because you need a whitelisted IP to call the web service.

Or I can paste here the entire code.

Okay, beside that, maybe you can check raw input/output in postman and compare to the DebugMessages from CURLSMBS class.

There may be a small difference like a header different.

You may set DebugWithData = true for CURLSMBS class to include data in the debug log.

By the way I think the problem is here current_params":"{}" but I’m passing the parameters in the url…

{"DataServiceFault":{"current_params":"{}","source_data_service":{"data_service_name":"PagamentiScolasticiDataService","description":"N/A","location":"/PagamentiScolasticiDataService.dbs","default_namespace":"http://ws.wso2.org/dataservice"},"ds_code":"INCOMPATIBLE_PARAMETERS_ERROR","current_request_name":"_getgetpagamentimensa"}}

solved, the problem was

header.Append("Content-Type: application/json; charset=UTF-8")

That caused a 500 Internal Server Error‽

I think the auth was ok, the problem was here

{“DataServiceFault”:{“current_params”:“{}”,“source_data_service”:{“data_service_name”:“PagamentiScolasticiDataService”,“description”:“N/A”,“location”:“/PagamentiScolasticiDataService.dbs”,“default_namespace”:“http://ws.wso2.org/dataservice"},“ds_code”:“INCOMPATIBLE_PARAMETERS_ERROR”,“current_request_name”:"_getgetpagamentimensa”}}

I’m sorry, I didn’t mean suggest I could help debug this any further. I don’t think I have enough information from the outside to understand anything about what happened here.

So I’m quite glad it’s working for you!

thank you for the support

1 Like