Yes, you're allowed to upsert against a Salesforce ID. You can read more about this in the various documentations, such as REST and SOAP. In fact, in some objects, you can even use the Name field, as long as the idLookup property is true for that field. In fact, the documentation even calls this out explicitly:
This example uses the POST method as a special ...
Like the error you're getting says, you can't have a string literal (text enclosed inside of single quotes 'like this') span multiple lines.
String myStr = 'Haikus are easy
but sometimes don\'t make much sense
If you need to have a multiline string (if for nothing but keeping things organized and easy to read), then you need to have a ...
You need to ensure that the Lightning scheduler is configured in your org. If Scheduler is configured, you will no longer see 'Service not found at: /services/data/v46.0/scheduling/' and the URI /services/data/v46.0/scheduling/should return valid resource values as below:
"getAppointmentCandidates" : "/services/data/v46.0/scheduling/...
Since you have a class that represent such data structures you could utilize typed deserialization:
JSON2Apex accountInfo = (JSON2Apex) JSON.deserialize(jsonString, JSON2Apex.class);
At this point you just have to loop on data property, then access to attributes one and you can get the value of fieldcode1.
This for-loop should do the trick: