Yetiforcecrm: [Question] Rest API, how to setup and use?

Created on 17 Oct 2019  ยท  59Comments  ยท  Source: YetiForceCompany/YetiForceCRM

Description

Hello, I can't find anywhere a documentation that say how to setup and use API, I'm about to create a connector between this CRM and an existing ERP system, but I don't know where to start from YetiForce.

I found just this partial documentation in other tickets, but isn't enough explicit.

Someone know a place where to find a documentation or can suggest me how to use YetiForce API?

Thank you in advance. ๐Ÿ˜„

  • [x] Understood way
  • [x] Got slightly enough documentation
  • [x] Got examples
  • [x] Activated webservices by php
  • [ ] Solved all problems
  • [ ] In production! ๐Ÿ˜ƒ
โ” question

All 59 comments

https://github.com/YetiForceCompany/YetiForceScripts/tree/master/YetiREST

Thank you, this is very useful!
I have just some questions to ask.

  1. I undestood I must create a WebService Application from YetiForce, in the field "URL" what I have to put?

  2. "$host = 'https://gitdeveloper.yetiforce.com/';" must be replace with my standard YetiForce address? e.g. "https//10.0.0.XX/" (local address while in develop)

  3. "$baseurl;" where forward?

  4. In the example "https://gitdeveloper.yetiforce.com/webservice/Users/Login", the word "webservice" must be replaced with the name of my application? e.g. "https://10.0.0.XX/YetiConnector/User/Login? I tried to ping links like this but I had only 404 errors.

Thank you in advance ๐Ÿ˜„

How to set up API:

First you need to create a web service application
Integration -> Web Service application and Add key

URL is just for you to know where are you accessing from, it does not matter.
name and password is what you will use as basic auth as username and password.
image

then create a webservice user
the user and password you create there you have to add it in the body as this
image

and lastly copy the token
image

in the webservice application with the copy button next to the edit one
and add it like this
image

tadaaaaa

Thank you @javjim but doesn't work ๐Ÿ˜ž

image

invalid URL
CRM_URL/webservice/Users/Login

Yep, looks like after this, you need to first use Users/Login, and it will give you back a Token, that you need to add as a header with x-token:value and then you should be able to do stuff

invalid URL
CRM_URL/webservice/Users/Login

I did 2 attempts

image

image

show me your yetiforce web app and web users..

show me your yetiforce web app and web users..

image

image

try with https://URL/webservice.php?module=Users&action=Login

This return something
image

The same result is returned also with "https://URL/webservice.php", which webservice should be activated? In webapplication it is active

you need to activate it in config/Api.php

https://github.com/YetiForceCompany/YetiForceCRM/blob/developer/tests/setup/Api.txt#L20-L21

There was enabled only dav, I just changed with dav and webservice and now it answer "Wrong credentials", I tried with my YetiForce login credentials and with WebService User credentials but same situation.

image

image

image

Ok, credentials are

  • userName: WebService Application Name
  • password: WebService Application Password

now the problem is "Internal Server Error":

image

where can I find a log or some suggestions to fix this problem?

I'm following the issue.
I got the same problem _Internal Server Error_ when trying to execute login call

show the body tab

show the body tab

This is the body tab
image

I tried API call with Demo server, it works, the login return to me the token, so maybe the problem is in my server, how can I find where is this problem?

change to form-data instead of x-www-formurlencoded

image

image

sorry, don't know what to tell you, verify all the steps, that is how I have it and it works properly, did you use the test and test123 username and password too? or you are just copying mine?

I created and used test and test123 in my Webservice Users.

I understood how it works, I tried call with the Demo server, the problem is, how can I set my YetiForce installation to answer as Demo server? I installed YetiForce correctly, following all steps and configuring my server as YetiForce requirement page ask. Maybe I have to activate something else?

looks like you have a server configuration problem

looks like you have a server configuration problem

where can I see this?

No sorry, I was asking: where can I check to find the problem on my configuration? Some logs? Some pages?

check all log logs: apache FPM php crm

I can't find any useful information by logs.
I installed the last version of YetiForce (5.2), I created an application an user for that application, I get the exactly same problems:
image

image

The server configuration:
image

opcache.interned_strings_buffer can't be more than 52 else page doesn't answer
output_buffering is set On in both configurations but appears 1 and empty on configuration page

enable showing errors: https://github.com/YetiForceCompany/YetiForceCRM/blob/developer/config/Debug.php#L88

Response:
{"status":0,"error":{"message":"2: array_merge(): Argument #1 is not an array in \/var\/www\/html\/yetiforce\/api\/webservice\/Core\/Request.php, line 43","code":200}}

Code:
image

whats that x-encrypted? and also again, use form-data in body.

whats that x-encrypted? and also again, use form-data in body.

I don't know why it autochanges to x-www-form-urlencoded, btw ok, with form-data it works, thanks you :)

To close issue, I need to achieve just another answer, why works with ../"webservice.php?module=Users&action=Login" and not with "../webservice/Users/Login"?
image

How to get list record via api by sort order

@Sasamous check if you have it turned on mod_rewrite

@mariuszkrzaczkowski
image

check this: #4154

Perfect, this worked, I had to enable "rewrite" from mods.

I used this commands:
a2enmod rewrite
systemctl restart apache2

Thank you all ๐Ÿ˜„

So, login return token, token is accept by other api calls, but it always return {"status":0,"error":{"message":"No permissions for module","code":403}}, I tried to follow code flow and I reached this file: ../app/Privilege.php lines 91~95:

if (!Module::isModuleActive($moduleName)) {
    static::$isPermittedLevel = 'SEC_MODULE_IS_INACTIVE';
    \App\Log::trace('Exiting isPermitted method ... - yes');
    echo (Module::isModuleActive($moduleName) ? "Enabled " : "Disabled ").$moduleName; //I added this code to check problem
    return false;
}

So I get this when I try calls:
image

BaseAction seems to be disabled, how can I enable it?

Fixed 7d55a95
see now https://doc.yetiforce.com/api/#/BaseAction/Api%5CPortal%5CBaseAction%5CModules%3A%3Aget

Works on demo page, but I don't have "api" folder in "public_html" folder, I'm on 5.2-Complete

image

How can I solve on my installation?

I could just comment the return false; and it works, but there is a better way? I don't want allow all requests without a filter

Cause I didn't solved my problem, I'm using demo Yetiforce for test API, but I get this error:

{"status":0,"error":{"message":"No permissions to view record","code":403,"backtrace":"#0 api\/webservice\/Portal\/BaseModule\/Record.php (62) >> Api\\Core\\Exception->__construct('No permissions to view record',403)\n#1 api\/webservice\/Core\/BaseAction.php (28) >> Api\\Portal\\BaseModule\\Record->checkPermission()\n#2 api\/webservice\/Controller.php (87) >> Api\\Core\\BaseAction->checkAction()\n#3 webservice.php (15) >> Api\\Controller->process()\n#4 public_html\/webservice.php (11) >> require('webservice.php')"}}

when I try to make this call:
https://gitdeveloper.yetiforce.com/webservice.php?module=Vendors&action=Record&record=368

I'm using "[email protected]" (administrator) user, all other calls I tried works

@mariuszkrzaczkowski

check if user api has permissions for this record

check if user api has permissions for this record

Yes, the user have permissions, with that user I can see the page

image

image

@mariuszkrzaczkowski User have premissions, I checked and modified my demo session in different ways, nothing helps, maybe is a bug for that module?
By the way, how can I get this fix https://github.com/YetiForceCompany/YetiForceCRM/issues/11770#issuecomment-545848092 on version 5.2 (Complete)? Must I uninstall everything again and download a non-stable version to get a more working (but not completely working) API system?

2 things, use as different issue for different questions, also, that issue you have is the same I am having here right? https://github.com/YetiForceCompany/YetiForceCRM/issues/11841 can you add your info there

Yes, it is the same response but in Demo Environment I can get ../Contacts/Record/recordID, my problem is in ../Vendors/Record/recordID

#11841 (comment)

Shouldn't it set by default for every module? So I can access everything from API by default, if I need to exclude something I could disable it by that field ๐Ÿ™‚ @mariuszkrzaczkowski

Btw today it works without this fix, I dunno why, maybe a new commit fixed it (on demo version).

I will maintain opened my issue until a full API functionality isn't implemented, I'm creating a complete connector between YetiForce and C++ ERP Systems, so I must use all API calls in all ways for that reason.

how to get sum total records by x-condition via api

@ezbank create a new issue

I'm asking for a complete API documentation, I like you added this to 5.3 Milestone, but you can't close this until you wrote a full API Documentation.

I see you used Swagger to give some examples of "Record" action, but there are a lot of other actions (Dashboard, Fields, Hierarchy, Pdf, PdfTemplates, Privileges, RecordRelatedList, RecordsList..) so how can users use those actions?

Also, where do you show body headers? Like x-condition, x-fields..
I expect you will close this post when you get a documentation of your API System.

Thanks for your commitment ๐Ÿ˜ƒ

but you can't close this until you wrote a full API Documentation.

Of course I can :)

but you can't close this until you wrote a full API Documentation.

Of course I can :)

Yes, but it is clear you are randomly closing issues that aren't really closed and adding them to 5.3 Milestone to increase the "Complete" percentage instead of taking care of opened issues :)

I don't know what makes you think that if you ask for complete documentation the issue will be open until this "demand" of yours is met. The documentation is the way it is, if you don't think it's complete you can always expand it.

If you don't want to pay then accept the current state of the application/documentation.

If you do want to pay then, for a fee, we can expand the documentation, teach you how to use API, solve API issues. The whole community will surely be thankful to you if you spend several thousand โ‚ฌ on the API documentation.

I'm actually working on your product by creating a connector between your CRM and several ERP Systems;

so your CRM will increase users by a lot once we (me and my team) finish the project.

But if your product is incomplete, because you don't have a documentation on how to use it, and you ask your users (who in this case are actually working for your CRM) to pay several thousand โ‚ฌ to ask you to work on your project just by writing a documentation, that should be the first thing to do in a public software, I don't think we are creating a connect between ERP Systems and the right CRM System.

By the way, I'm actually creating a sort of documentation in your GitHub issues section, by creating very detailed issues with tons of information useful for you and for who is reading, so your community is already thankful to me.

So, your request to users to

spend several thousand โ‚ฌ on the API documentation.

is pretty ridiculous because it means your software isn't really free if users can't use it without paying it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

scsikid picture scsikid  ยท  3Comments

Raggazzoo picture Raggazzoo  ยท  3Comments

rskrzypczak picture rskrzypczak  ยท  3Comments

ezbank picture ezbank  ยท  3Comments

RedMoon27 picture RedMoon27  ยท  3Comments