• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Error to send Firebase token to Wordpress plugin (missing os parameter)

I'm trying to connect posts from a Wordpress website using the Wordpress plugin and Firebase for cloud messaging. So whenever there's a new post in the website, the app users will receive a notification about it First, I need to send an API POST request with the device's token to the plugin. Ex:

URL structure: http://yoursite/pnfw/register/

Method: POST

Parameters: token (string): token given by APNs or FCM identifying the device, often called device ID (read here for devices without token, e.g. iOS simulator). os (string): operating system. It must be iOS or Android (case sensitive).

--Sample request for new registration: POST /pnfw/register/ HTTP/1.1 Host: yoursite Content-Length: 26 Content-Type: application/x-www-form-urlencoded


It is working when I test the API, but Android Studio keeps sending me this response:

2021-06-16 16:18:20.488 24664-24664/com.bc.brendan.soccernbandroidapp I/ResponseMsg: {"error":"500","reason":"Internal Server Error","detail":"Mandatory parameter os missing"}


Request{method=POST, url=https://myWebSite.org/appdev/pnfw/register?token=fiCob....cdJmg2&os=Android, tags={class retrofit2.Invocation=com.bc.brendan.myApp.JsonPlaceholderAPI.createRegister() [fiCob...cdJmg2, Android]}}

Code for the Firebase class:

package com.bc.brendan.myApp;

import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.NonNull;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import androidx.annotation.NonNull;

import java.io.IOException;
import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.POST;
import retrofit2.http.Query;

public class FirebasePush extends FirebaseMessagingService {

public FirebasePush() {

private String newToken;
private JsonPlaceholderAPI jsonPlaceholderAPI;

public void onMessageReceived(@androidx.annotation.NonNull RemoteMessage remoteMessage) {

public void onNewToken(String token) {
Log.e("newToken", token);
newToken = token;


private void sendToken() {
Register register = new Register(newToken, "Android");

Retrofit retrofit = new Retrofit.Builder()
jsonPlaceholderAPI = retrofit.create(JsonPlaceholderAPI.class);

Call<Register> call = jsonPlaceholderAPI.createRegister(register.getToken(), register.getOs());

call.enqueue(new Callback<Register>() {
public void onResponse(Call<Register> call, Response<Register> response) {
try {
Log.i("ResponseMsg", response.errorBody().string());
} catch (IOException e) {

public void onFailure(Call<Register> call, Throwable t) {
Log.i("ErrorMsg", t.getMessage());

Json placeholder interface:

package com.bc.brendan.myApp;

import java.util.List;

import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;

public interface JsonPlaceholderAPI {

Call<List<Post>> getPosts();

Call<Register> createRegister(@Query("token") String token,
@Query("os") String os);

Any help would be appreciated. I've been stuck in this issue for three days now.


We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.