function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andrew B 1Andrew B 1 

Apex REST WebService ERRORS

I am trying to do the following:
Write a apex REST webservice that takes in data to write 2 or more related objects.  You can use the out of the box objects or create new ones.

I am getting the following errors:
User-added image
And:
User-added image

Please assist. With the first one I think part of my confusion is how the class attributes are formed. I tried going to what I thought was the proper documentation but still getting that error.

With the second one I'm not sure if it dislikes more than one class in a single apex file?
Here is my code:
@RestResource(urlMapping='/Accounts/*')
global with sharing class AccountsManager {

       @HttpPost
    global static ID createAccount(String accountOwner, String accountName,
        String accountPhone, String accountWebsite) {
        Account thisAccount = new Account(
            Account Owner=accountOwner,
            Account Name=accountName,
            Phone=accountPhone,
            Website=accountWebsite);
        insert thisAccount;
        return thisAccount.Id;
    } 
}

@RestResource(urlMapping='/Contacts/*')
global with sharing class ContactsManager {

       @HttpPost
    global static ID createContact(String contactOwner, String contactFirstName,
        String contactLastName, String contactTitle, String contactEmail) {
        Contact thisContact = new Contact(
            Owner=contactOwner,
            First Name=contactName,
            Last Name=contactLastName
            Title=contactTitle,
            Email=contactEmail);
        insert thisContact;
        return thisContact.Id;
    } 
}