There is a lot going on here.
Yes, the quotes are required as # is a comment symbol in the shell and the rest of the command line is discarded.
You either use colorindex or backgroundcolor/foregroundcolor but not both. Valid values for colorindex are 1 to 24.
If you lookup the values for colorindex 1, you get background color #ac725e and foregroundcolor #1d1d1d.
If you use the API to set these values you get an error on the foregroundcolor. If fact it appears that #000000 is the only acceptable value for foregroundcolor.
If you use the API to set the colorindex to 1, the response says that the backgroundcolor was set to #ac725e and the foregroundcolor was set to #000000, not #1d1d1d.
So, I'd give up on foregroundcolor.
But, there is a coding error in GAM that prevents backgroundcolor from being properly interpreted by the API. I have sent the corrections to Jay.
If you have the UNIX version of GAM and require an immediate fix and know what you're doing, here is a diff (on GAM 3.51) that shows the correction.
addCalendar
1593a1594
> colorRgbFormat = False
1635a1637
> colorRgbFormat = True
1638a1641
> colorRgbFormat = True
1650c1653
< callGAPI(service=cal.calendarList(), function=u'insert', body=body)
---
> callGAPI(service=cal.calendarList(), function=u'insert', body=body, colorRgbFormat=colorRgbFormat)
updateCalendar
1657a1661
> colorRgbFormat = False
1686a1691
> colorRgbFormat = True
1689a1695
> colorRgbFormat = True
1714c1720
< callGAPI(service=cal.calendarList(), function=u'update', calendarId=calendarId, body=body)
---
> callGAPI(service=cal.calendarList(), function=u'update', calendarId=calendarId, body=body, colorRgbFormat=colorRgbFormat)
Ross