Update build_query for mid

Find everything that uses build_query and change uri it to mid.