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
dai tran 6dai tran 6 

Why can't call a httppost of Rest API?

Apex calss:
@HttpPost
        global static Integer checklogin(String email, String password ) {
              
                List<AccountUser__c>  listacc =  [SELECT email__c,Password__c,AccountId__r.type FROM AccountUser__c   WHERE Status__c=1 and email__c=:email and Password__c=:password   LIMIT 1];       
                if(listacc.size()>0)
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
           
        }

I call Rest API from android:
                     url = "https://test-dev-ed.my.salesforce.com/services/apexrest/AccountUsers/"
                         client = OkHttpClient()

                         jsonIn = FormBody.Builder()
                                .add("email","tranbadai1@@gmail.com")
                                .add("password","123456")
                                .build()

                         request = Request.Builder()
                                 .post(jsonIn)
                                .header("Authorization", "Bearer "+accesstoken)
                                .addHeader("Content-Type", "application/json")
                                .url(url)
                                .build()
                     
                             response = client.newCall(request).execute()
Error:
[{"errorCode":"UNSUPPORTED_MEDIA_TYPE","message":"Content-Type header specified in HTTP request is not supported: application/x-www-form-urlencoded"}]