Skip to content

Issue in Create App Key function - when passing comma separated API products error is returned #202

Open
@RitvijKacha71

Description

@RitvijKacha71

Passing comma separated API product values while invoking Creat App key, below error is returned from associateKeySecret function.

Error:
Associate KeySecret result: {"code":"cps.kms.ApiProductDoesNotExist","message":"API Product [{apiproduct1},{apiproduct2}] does not exist for tenant [32e6baf6] and id [null]","contexts":[]}

Solution:
Below particular line of code (createappkey.js line number 106) is incorrect. Incoming api product string is assigned as is within square brackets without splitting which results in single string with comma separated api product value i.e.
['Bronze,Gold'] which ideally should be ['Bronze','Gold'] after splitting up.

var prods = opts.apiProducts;
if (typeof prods === 'string') {
prods = [prods];
}

Reference:

createApp.js line number 68 has same functionality where api products are split and stored into array. Need to apply same logic in createAppKey.js instead of directly assigning apiproduct string with in square brackets.
if(opts.apiProducts){
var split = opts.apiProducts.split(',')
split.forEach(function(s){
if(s && s.trim()!= '') {
app.apiProducts.push(s.trim())
}
})
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions