Apex REST

Call custom Apex REST endpoints.

GET Request

Go
var result MyResponse
err := client.Apex().GetJSON(ctx, "/MyService/v1/accounts", &result)
fmt.Println("Data:", result.Data)

POST Request

Go
request := map[string]interface{}{
    "name": "New Account",
    "type": "Customer",
}

var response CreateResponse
err := client.Apex().PostJSON(ctx, "/MyService/v1/accounts", request, &response)

Raw Response

Go
// Get raw bytes
body, err := client.Apex().Get(ctx, "/MyService/v1/data")

// Post raw bytes
body, err := client.Apex().Post(ctx, "/MyService/v1/process", myData)

PATCH / PUT / DELETE

Go
// PATCH
body, _ := client.Apex().Patch(ctx, "/Accounts/123", updateData)

// PUT
body, _ := client.Apex().Put(ctx, "/Accounts/123", replaceData)

// DELETE
body, _ := client.Apex().Delete(ctx, "/Accounts/123")

Apex REST Service Example

Apex
@RestResource(urlMapping='/MyService/v1/*')
global class MyRestService {
    @HttpGet
    global static String doGet() {
        return 'Hello from Apex!';
    }
    
    @HttpPost
    global static String doPost(String name) {
        return 'Created: ' + name;
    }
}

Available Methods

Method Description
Get() GET request, returns bytes
GetJSON() GET with JSON unmarshal
Post() POST request, returns bytes
PostJSON() POST with JSON marshal/unmarshal
Patch() PATCH request
Put() PUT request
Delete() DELETE request