0
// @abi action
    [[eosio::action]]
    void create(name user,string doctor_name,string doctor_contact,string doctor_address,string patient_problem,string patient_description,string patient_solution){

        require_auth( user ); //require auther permission

        record_index datable( _self,_code.value); // Define database object

        datable.emplace( user, [&](report & r){

            r.report_poster = user;
            r.report_id = datable.available_primary_key();
            r.doctor_name = doctor_name;
            r.doctor_contact = doctor_contact;
            r.doctor_address = doctor_address;
            r.patient_problem = patient_problem;
            r.patient_description = patient_description;
            r.patient_solution = patient_solution;
        }); // create data in database
}

This is the EOSIO action for which I want to create an API. How do I proceed?

  • 2
    What exactly are you trying to do? Which programming language/framework are you using for your server? – TeeAttack42 Mar 27 '19 at 15:06
  • i am using eosjs and node.js – Milan Aghera Mar 28 '19 at 5:29
  • Try to make api by nodejs follow this tutorialspoint.com/nodejs/nodejs_restful_api.htm to know about api in nodejs. – Mr.Y Mar 28 '19 at 5:34
  • I know that but it did not work – Milan Aghera Mar 28 '19 at 5:50
  • It works i have tried – Mr.Y Mar 28 '19 at 12:05
0

If you want to run create action through eosjs, then you need to set your active key what you upload contract.

I think the reason why "it did not work" may following causes.

1) no right to run contract action. your contact action have this statement "require_auth( user ); "

2) no proper options for eosjs

3) no proper settings for network

BTW, do you run setabi and setcode for this contract?

anyway, if you upload error statement when you try node.js server, it will be helpful to resolve this issue.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.