Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question]: Example seems to throw an 'app_id' not found error #21

Closed
1 task done
EwanValentine opened this issue Jan 5, 2023 · 1 comment
Closed
1 task done

Comments

@EwanValentine
Copy link

How can we help?

I've pulled some of the examples from this repo, creating a 'player' and sending a notification:

func main() {
	notification := *onesignal.NewNotification("<app-id>")

	configuration := onesignal.NewConfiguration()
	apiClient := onesignal.NewAPIClient(configuration)

	appAuth := context.WithValue(context.Background(), onesignal.AppAuth, "<api-key>")

	player := *onesignal.NewPlayer("7c9b2780-c3ae-4f89-8776-64b112896aff", 0)
	resp, r, err := apiClient.DefaultApi.CreatePlayer(appAuth).Player(player).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.CreatePlayer``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
		return
	}

	// response from `CreateNotification`: CreateNotificationSuccessResponse
	fmt.Fprintf(os.Stdout, "Response from `DefaultApi.CreateNotification`: %v\n", resp)

	notificationResp, r, err := apiClient.DefaultApi.CreateNotification(appAuth).Notification(notification).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.CreateNotification``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	// response from `CreateNotification`: CreateNotificationSuccessResponse
	fmt.Fprintf(os.Stdout, "Response from `DefaultApi.CreateNotification`: %v\n", notificationResp)
}

However, this seems to throw an error:

{{"errors":["app_id not found. You may be missing a Content-Type: application/json header."]}}

I am setting the app ID, and as I'm using an SDK, I'm not sure that I can set the 'Content-Type' headers, or even need to. Any ideas what I'm doing wrong here?

Thanks!

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jennantilla
Copy link

Hello there! Apologies that this issue was missed. Since quite some time has passed since this was reported, we're going to close this issue. If you are still having trouble on the latest release, please open a new issue with updated reproduction steps and we will be happy to assist!

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

No branches or pull requests

2 participants