Solved. This is what I learned from this issue and hopefully it can help someone else.
When specifying an array in configoptions, the syntax is : array(xxx1 => yyy1, xxx2 => yyy2).
xxx is the optionid while yyy is the value. In above line, there are two options. Each option pair is separated by comma.
Another important thing is to check your parameters in the API. For example, API AddOrder has a parameter pid. It must use an integer array. If you just pass it with a single value, the order is added, but the configoptions is totally ignored by the API and without generating a warning message.
This is one area WHMCS can improve upon. APIs should generate more warning messages.
Thanks
Mike