[SalesForce] Migrating Named Credential with password

I retrieved a Named credential using Ant migration tool and in the xml it looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<NamedCredential xmlns="http://soap.sforce.com/2006/04/metadata">
    <endpoint>https://prodbox-dev.herokuapp.com/v1</endpoint>
    <label>prodbox_heroku</label>
    <principalType>NamedUser</principalType>
    <protocol>Password</protocol>
    <username>technical.user.prod@techuser.dev</username>
</NamedCredential>

when i deploy the same using ant, it gives error for password.
Due to this i have to go and manually create a named credential as a pre-deployment activity. Can password be also set in this xml and deployed using Ant ?

Best Answer

adding password manually after retrieve and before deploy worked :

<?xml version="1.0" encoding="UTF-8"?>
<NamedCredential xmlns="http://soap.sforce.com/2006/04/metadata">
    <endpoint>https://prodbox-dev.herokuapp.com/v1</endpoint>
    <label>prodbox_heroku</label>
    <principalType>NamedUser</principalType>
    <protocol>Password</protocol>
    <password>actual_password</password>
    <username>technical.user.prod@techuser.dev</username>
</NamedCredential>
Related Topic