improve building of api query, handle missing mydata case