Message Boards Message Boards

Implement 'curl' command with URLRead, HTTPRequest, etc.

Posted 13 days ago

I am attempting to access the list of projects from a private/internal GitLab host with ML's URLRead function. I have been successful accessing the data via a browser as well as from the following command in a terminal:

curl --cert /path/to/certs.pem:its_password --header "Authorization: Bearer users_personal_access_token" https://private.gitlab.com/api/v4/projects

(with the proper values of 'its_password', 'users_personal_access_token', and 'private.gitlab.com' private git lab host). Unfortunately in WL I am unable to replicate the query with various iterations of the following:

URLRead[
    HTTPRequest[
        "Scheme"->"https",
        "Domain"->"private.gitlab.com",
        "Path"->"/api/v4/projects"
    ],
    All,
    Authentication-><|
        "Headers"-><|"Authorization"->"Bearer users_personal_access_token"|>,
        "PEMFile"->"/path/to/certs.pem",
        "PEMFilePassword"->"its_password"
    |>
]

The URLRead returns errors "400 No required SSL certificate was sent." The various iterations are moving things around, such as removing the "Authentication->..." and moving the "Header"->... inside the HTTPRequest above it; also replacing "PEMFile" (etc.) with "ClientCertificate", "CertificateFile", depending on how Mathematica Stack Exchange, Microsoft Copilot, and Claude feel that day. Even took Wireshark traces of "curl" and "URLRead"; that was overwhelming and did not manage to get any useful comparison due to my lack of experience.

Have you been successful querying services that require authentication (particularly GitLab)? How did you do it? Any assistance would be great, and thank you for your time.

POSTED BY: Ed Estrella

My preferred way to solve git authentication issues is to connect using ssh instead of http and add my public key the server as an authorized key in the .ssh directory. But I understand that this is not always possible.

If you want to go low level, this might help: https://community.wolfram.com/groups/-/m/t/181627

POSTED BY: Gustavo Delfino
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract