I expect curl is seeing it as different URLs, that is, your curl command is
curl --silent http://192.168.x.xxx/rr_delete?name=0:/gcodes/3dprinting square test.gcode so curl is going to URL http://192.168.x.xxx/rr_delete?name=0:/gcodes/3dprinting and then to square and then to test.gcode. URLs cannot contain spaces.
Try file = "3dprinting%20square%20test.gcode"
Or file = "3dprinting+square+test.gcode" (but this is definitely the wrong way to do it, though it might work).