Using CURLSMBS with a rest api

Given api docs for logging in like this:

curl -X POST --user email@company.com:password “https://api.company.com/v1/login.json

I’m trying to use the MBS Curl plugin, but I keep getting a 400 Bad Request back.

Here’s what I’m trying:

dim c as new MyCurl
dim cacert as FolderItem = GetFolderItem(“cacert.pem”)

c.OptionHTTPAuth = 1
c.OptionVerbose=true
c.OptionURL = “https://api.company.com/v1/login.json
c.OptionUsername = “email@company.com:myPassword”
c.OptionPost = true
c.CollectDebugData = True
c.CollectOutputData = true
c.OptionHeader=true
c.CollectHeaderData = true
c.OptionSSLVerifyHost = 2 // verify server
c.OptionSSLVerifyPeer = 1 // proofs certificate is authentic
c.OptionCAInfo = cacert.ShellPath

dim e as integer = c.Perform
msgbox "Result: "+str(c.Perform)
system.DebugLog(c.OutputData)

Any obvious problem I missed?

I also tried setting the password separately with c.OptionPassword, but same result.

In a possible outdated tutorial video, they used c.OptionUsernamePassword, with the username and password concatenated with a colon, but that option seems to no longer exist in the latest version of the plugin.

OptionUsernamePassword was removed. Simply use other

Do you see in DebugData the request and response. Those details would help.

In a recent project, it helped to use SetOptionHTTPheader with

Content-Type: text/javascript; charset=utf-8
Expect:
Transfer-Encoding:

those options will tell the content type and disable encodings or chunked transfer.

Thanks! I found that if I set OptionPostFields = “”, then everything worked. Weird!