Getting no session information while deleting app from argoCD using API

1/18/2022

I am trying to delete the ArgoCD app from the API, but getting no session information while calling the Delete API.

{"error":"no session information","code":16,"message":"no session information"}

In the swagger, it seems pretty much easy

enter image description here

https://myargocd.example.com/swagger-ui#operation/ApplicationService_Delete

I already set ENV for the token

ARGOCD_TOKEN=my-token
-- Adiii
argocd
kubernetes

1 Answer

1/18/2022

I need to pass the ArgoCD token as a cookies header to the delete API.

For

<=v1.2

Then pass using the HTTP SetCookie header, prefixing with argocd.token:

$ curl $ARGOCD_SERVER/api/v1/applications --cookie "argocd.token=$ARGOCD_TOKEN" 
{"metadata":{"selfLink":"/apis/argoproj.io/v1alpha1/namespaces/argocd/applications","resourceVersion":"37755"},"items":...}

v1.3

Then pass using the HTTP Authorization header, prefixing with Bearer:

$ curl $ARGOCD_SERVER/api/v1/applications -H "Authorization: Bearer $ARGOCD_TOKEN" 
{"metadata":{"selfLink":"/apis/argoproj.io/v1alpha1/namespaces/argocd/applications","resourceVersion":"37755"},"items":...}

https://argo-cd.readthedocs.io/en/stable/developer-guide/api-docs/#authorization

and finally my function is able to delete apps from the ArgoCD

async function deleteApp(AppName){
    let url = 'https://argocd.exampple.com/api/v1/applications/'+AppName
    let res = await fetch(url, {
        headers: {
            Cookie: 'argocd.token=' + process.env.ARGOCD_AUTH_TOKEN 
        },
        method: 'DELETE'
    })
    let body = await res.json()
    return body
}
-- Adiii
Source: StackOverflow