Skip to content

Request response style api support#263

Draft
mohitpubnub wants to merge 4 commits into
masterfrom
request-response-api-support
Draft

Request response style api support#263
mohitpubnub wants to merge 4 commits into
masterfrom
request-response-api-support

Conversation

@mohitpubnub

@mohitpubnub mohitpubnub commented Sep 25, 2025

Copy link
Copy Markdown
Contributor

Simple Usage (Builder Pattern)

var result = await pubnub.Publish()
    .Message("Hello World")
    .Channel("my-channel")
    .ExecuteAsync();

Advanced Usage (Request/Response Overload)

var response = await pubnub.Publish(new PublishRequest
{
    Message = new { text = "Hello", metadata = "value" },
    Channel = "my-channel",
    StoreInHistory = true,
    Ttl = 24,
    Metadata = new Dictionary<string, object> { { "type", "notification" } },
    UsePost = true
});

Error Handling

try
{
    var response = await pubnub.Publish(request);
    Console.WriteLine($"Published with timetoken: {response.Timetoken}");
}
catch (ArgumentException ex)
{
    Console.WriteLine($"Validation error: {ex.Message}");
}
catch (PNException ex)
{
    Console.WriteLine($"PubNub error: {ex.Message}");
}

@pubnub-ops-terraform

pubnub-ops-terraform commented Sep 25, 2025

Copy link
Copy Markdown

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants