API for ERPNext

Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.

https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py

Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Great!

Any chance you add a “read” method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



W: https://erpnext.com
T: @rushabh_mehta



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.














You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Also updated webclient.py:



On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.












Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login–we get a 404 response.  We are trying variations of “http://{our local erpnext server}/webnotes/erpnext_master/public/server.py” as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, “http://{our local erpnext server}/public/server.py”. Can you give us any hints about what the url should be? (We also tried “client.py” instead of “server.py”).

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct “client.py” file into the proper location. Can you tell us how to ascertain whether we have the correct file and it’s in the expected place?  Once it’s in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:



On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u’message’: u’‘, u’exc’: u’“Traceback (innermost last):\n  File \”…/lib/webnotes/handler.py\“, line 159, in handle\n execute_cmd(cmd)\n  Fil
e \”…/lib/webnotes/handler.py\“, line 176, in execute_cmd\n method = get_method(cmd)\n  File \”…/lib/webnotes/handler.py\“, line 218, in ge
t_method\n    method = globals()[cmd]\n KeyError: u\”['login', 'login']\“\n”'}

Any suggestions?

Thanks again.


PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login–we get a 404 response.  We are trying variations of “http://{our local erpnext server}/webnotes/erpnext_master/public/server.py” as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, “http://{our local erpnext server}/public/server.py”. Can you give us any hints about what the url should be? (We also tried “client.py” instead of “server.py”).

Don’t use /public/server.py — just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set “server” to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct “client.py” file into the proper location. Can you tell us how to ascertain whether we have the correct file and it’s in the expected place?  Once it’s in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply. We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response. We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address. Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place? Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.












Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


For more options, visit https://groups.google.com/groups/opt_out.





--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Here’s the redacted url returned from response.get().  Odd that all the params are doubled.


https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()–the code wouldn’t work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin


If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the ‘requests’ module.  Now the login is working…


- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir…@gmail.com> wrote:

Here’s the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()–the code wouldn’t work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin


If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/w6J1ZHMV2L8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Hi, sorry, me again.


We are trying to create–and optionally update–a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer (“johndoe123”), which is what we want the doctype to be referenced by, but we want the customer’s name to be “John Doe”. Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says “Document has been modified after you have opened it.”

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the ‘requests’ module.  Now the login is working…

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir…@gmail.com> wrote:

Here’s the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()–the code wouldn’t work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin


If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module.  Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Thanks for the reply. What we are trying to do is update a complex doctype from a script–specifically we are trying to update a BOM–that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.


The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn’t get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to “get” the customer after save, rename it and save gain. The system will only save if the incoming record’s “modified” property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir…@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create–and optionally update–a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer (“johndoe123”), which is what we want the doctype to be referenced by, but we want the customer’s name to be “John Doe”. Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says “Document has been modified after you have opened it.”

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the ‘requests’ module.  Now the login is working…

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir…@gmail.com> wrote:

Here’s the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()–the code wouldn’t work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin


If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 



You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Jonathan,

The way to do this would be to first get, update and push.

You can send the list of dicts (we call it a doclist) via a POST request. It should work - where are you getting stuck? Is there a specific error message?

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 17-Jan-2013, at 12:49 AM, Jonathan <ir...@gmail.com> wrote:

Thanks for the reply. What we are trying to do is update a complex doctype from a script--specifically we are trying to update a BOM--that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.

The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn't get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module.  Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Hi.  I am still unable to get update to work and am asking two specific questions.

1. We have a BOM doctype which contains a number of individual BOM Item doctypes. Is it possible to read and update an individual BOM Item from a BOM doctype, or must one read the entire BOM and update the whole thing at once? So far I have only managed to read the entire BOM, but not an individual BOM Item.

2: Since I cannot so far read individual BOM Items, I am trying to update the entire BOM doctype. My update script works successfully if the BOM contains only a single BOM Item, but fails if there are two BOM Items. Why is that?

My script uses the same functions for get_doc(), login(), update(), etc. that you posted here: https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py. In the original update function, the doclist is added to the params argument of requests.post(), which means the entire doclist is added to the request url. Specifically, I am doing the following:

doc = get_doc("BOM", bom)
rows = doc.json().get("message")
for row in rows
# change Qty if a certain condition is met
update(rows)

If there is one BOM Item in the BOM, the update is successful.  With two or more Bom Items, I get the following traceback:

Traceback (most recent call last):
  File "...\updateqty.py", line 187, in <module>
    main()
  File "...\updateqty.py", line 182, in main
    update(server, rows);
  File "...\updateqty.py", line 50, in update
    "doclist": json.dumps(doclist)
  File "...\updateqty.py", line 62, in request
    response = requests.post(server, cookies = {"sid": sid}, params=params)
  File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
    return request('post', url, data=data, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 222, in send
    r.content
  File "C:\Python27\lib\site-packages\requests\models.py", line 550, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "C:\Python27\lib\site-packages\requests\models.py", line 496, in generate
    chunk = self.raw.read(chunk_size)
  File "C:\Python27\lib\site-packages\requests\packages\urllib3\response.py", line 148, in read
    return self._fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 561, in read
    s = self.fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 1298, in read
    return s + self._file.read(amt - len(s))
  File "C:\Python27\lib\socket.py", line 380, in read
    data = self._sock.recv(left)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

If instead I try to extend the update to use the "data" argument (which puts the data into the body of the post rather than the url), something like:

response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)

where params= {
"cmd": "webnotes.client.save"
}
and data= {
"doclist": json.dumps(doclist) 
}

I get the following result from ERPNext:

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n    execute_cmd(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 191, in execute_cmd\\n    ret = call(method, webnotes.form_dict)\\n  File \\"../lib/webnotes/handler.py\\", line 210, in call\\n    return fn(**newargs)\\n TypeError: save() takes exactly 1 argument (0 given)\\n"'}

Can you suggest the right approach for updating either individual BOM Items or the entire BOM?

Thank you for your help.


 
Jonathan,

The way to do this would be to first get, update and push.

You can send the list of dicts (we call it a doclist) via a POST request. It should work - where are you getting stuck? Is there a specific error message?

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 17-Jan-2013, at 12:49 AM, Jonathan <ir...@gmail.com> wrote:

Thanks for the reply. What we are trying to do is update a complex doctype from a script--specifically we are trying to update a BOM--that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.

The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn't get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module.  Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/BiY2q-sq-2gJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Jonathan,

Your second approach is correct. You need to do a POST. You are not able send 2 items because of the URL limit in GET.

From the traceback, the parameters are not getting mapped correctly - can you debug the POST a bit?

I am sure you are pretty close to the solution.

best,
Rushabh



Hi.  I am still unable to get update to work and am asking two specific questions.

1. We have a BOM doctype which contains a number of individual BOM Item doctypes. Is it possible to read and update an individual BOM Item from a BOM doctype, or must one read the entire BOM and update the whole thing at once? So far I have only managed to read the entire BOM, but not an individual BOM Item.

2: Since I cannot so far read individual BOM Items, I am trying to update the entire BOM doctype. My update script works successfully if the BOM contains only a single BOM Item, but fails if there are two BOM Items. Why is that?

My script uses the same functions for get_doc(), login(), update(), etc. that you posted here: https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py. In the original update function, the doclist is added to the params argument of requests.post(), which means the entire doclist is added to the request url. Specifically, I am doing the following:

doc = get_doc("BOM", bom)
rows = doc.json().get("message")
for row in rows
# change Qty if a certain condition is met
update(rows)

If there is one BOM Item in the BOM, the update is successful.  With two or more Bom Items, I get the following traceback:

Traceback (most recent call last):
  File "...\updateqty.py", line 187, in <module>
    main()
  File "...\updateqty.py", line 182, in main
    update(server, rows);
  File "...\updateqty.py", line 50, in update
    "doclist": json.dumps(doclist)
  File "...\updateqty.py", line 62, in request
    response = requests.post(server, cookies = {"sid": sid}, params=params)
  File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
    return request('post', url, data=data, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 222, in send
    r.content
  File "C:\Python27\lib\site-packages\requests\models.py", line 550, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "C:\Python27\lib\site-packages\requests\models.py", line 496, in generate
    chunk = self.raw.read(chunk_size)
  File "C:\Python27\lib\site-packages\requests\packages\urllib3\response.py", line 148, in read
    return self._fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 561, in read
    s = self.fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 1298, in read
    return s + self._file.read(amt - len(s))
  File "C:\Python27\lib\socket.py", line 380, in read
    data = self._sock.recv(left)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

If instead I try to extend the update to use the "data" argument (which puts the data into the body of the post rather than the url), something like:

response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)

where params= {
"cmd": "webnotes.client.save"
}
and data= {
"doclist": json.dumps(doclist) 
}

I get the following result from ERPNext:

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n    execute_cmd(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 191, in execute_cmd\\n    ret = call(method, webnotes.form_dict)\\n  File \\"../lib/webnotes/handler.py\\", line 210, in call\\n    return fn(**newargs)\\n TypeError: save() takes exactly 1 argument (0 given)\\n"'}

Can you suggest the right approach for updating either individual BOM Items or the entire BOM?

Thank you for your help.


 
Jonathan,

The way to do this would be to first get, update and push.

You can send the list of dicts (we call it a doclist) via a POST request. It should work - where are you getting stuck? Is there a specific error message?

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 17-Jan-2013, at 12:49 AM, Jonathan <ir...@gmail.com> wrote:

Thanks for the reply. What we are trying to do is update a complex doctype from a script--specifically we are trying to update a BOM--that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.

The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn't get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module.  Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/BiY2q-sq-2gJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Hi Rushabh,


Had to change the update() method to use both params and data arguments, and the requests module under both mac and windows didn’t seem to fill in the POST request body. Finally got it all to work under linux.

def request(server, params=None, data=None):
    global sid
    
    if not sid: login()
    
    response = requests.post(server, cookies = {“sid”: sid}, params=params, data=data)


Thanks for the suggestions.

- j


On Monday, January 21, 2013 3:30:54 PM UTC+1, rushabh wrote:
Jonathan,

Your second approach is correct. You need to do a POST. You are not able send 2 items because of the URL limit in GET.

From the traceback, the parameters are not getting mapped correctly - can you debug the POST a bit?

I am sure you are pretty close to the solution.

best,
Rushabh



Hi.  I am still unable to get update to work and am asking two specific questions.

1. We have a BOM doctype which contains a number of individual BOM Item doctypes. Is it possible to read and update an individual BOM Item from a BOM doctype, or must one read the entire BOM and update the whole thing at once? So far I have only managed to read the entire BOM, but not an individual BOM Item.

2: Since I cannot so far read individual BOM Items, I am trying to update the entire BOM doctype. My update script works successfully if the BOM contains only a single BOM Item, but fails if there are two BOM Items. Why is that?

My script uses the same functions for get_doc(), login(), update(), etc. that you posted here: https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py. In the original update function, the doclist is added to the params argument of requests.post(), which means the entire doclist is added to the request url. Specifically, I am doing the following:

doc = get_doc(“BOM”, bom)
rows = doc.json().get(“message”)
for row in rows
# change Qty if a certain condition is met
update(rows)

If there is one BOM Item in the BOM, the update is successful.  With two or more Bom Items, I get the following traceback:

Traceback (most recent call last):
  File “…\updateqty.py”, line 187, in <module>
    main()
  File “…\updateqty.py”, line 182, in main
    update(server, rows);
  File “…\updateqty.py”, line 50, in update
    “doclist”: json.dumps(doclist)
  File “…\updateqty.py”, line 62, in request
    response = requests.post(server, cookies = {“sid”: sid}, params=params)
  File “C:\Python27\lib\site-packages\requests\api.py”, line 87, in post
    return request(‘post’, url, data=data, **kwargs)
  File “C:\Python27\lib\site-packages\requests\api.py”, line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File “C:\Python27\lib\site-packages\requests\sessions.py”, line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File “C:\Python27\lib\site-packages\requests\sessions.py”, line 374, in send
    r = adapter.send(request, **kwargs)
  File “C:\Python27\lib\site-packages\requests\adapters.py”, line 222, in send
    r.content
  File “C:\Python27\lib\site-packages\requests\models.py”, line 550, in content
    self.content = bytes().join(self.itercontent(CONTENT_CHUNK_SIZE)) or bytes()
  File “C:\Python27\lib\site-packages\requests\models.py”, line 496, in generate
    chunk = self.raw.read(chunk_size)
  File “C:\Python27\lib\site-packages\requests\packages<wbr>urllib3\response.py”, line 148, in read
    return self._fp.read(amt)
  File “C:\Python27\lib\httplib.py”, line 561, in read
    s = self.fp.read(amt)
  File “C:\Python27\lib\httplib.py”, line 1298, in read
    return s + self._file.read(amt - len(s))
  File “C:\Python27\lib\socket.py”, line 380, in read
    data = self._sock.recv(left)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

If instead I try to extend the update to use the “data” argument (which puts the data into the body of the post rather than the url), something like:

response = requests.post(server, cookies = {“sid”: sid}, params=params, data=data)

where params= {
“cmd”: “webnotes.client.save”
}
and data= {
“doclist”: json.dumps(doclist) 
}

I get the following result from ERPNext:

{u’message’: u’‘, u’exc’: u’“Traceback (innermost last):\n  File \”…/lib/webnotes/handler.py<wbr>", line 159, in handle\n    execute_cmd(cmd)\n  File \“…/lib/webnotes/handler.py<wbr>", line 191, in execute_cmd\n    ret = call(method, webnotes.form_dict)\n  File \”…/lib/webnotes/handler.py<wbr>", line 210, in call\n    return fn(**newargs)\n TypeError: save() takes exactly 1 argument (0 given)\n"'}

Can you suggest the right approach for updating either individual BOM Items or the entire BOM?

Thank you for your help.


 
Jonathan,

The way to do this would be to first get, update and push.

You can send the list of dicts (we call it a doclist) via a POST request. It should work - where are you getting stuck? Is there a specific error message?

- Rushabh



W: https://erpnext.com
T: @rushabh_mehta

On 17-Jan-2013, at 12:49 AM, Jonathan <ir...@gmail.com> wrote:

Thanks for the reply. What we are trying to do is update a complex doctype from a script--specifically we are trying to update a BOM--that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.

The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn't get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module.  Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/BiY2q-sq-2gJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/NDrHqRjqDQEJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Jonathan,

Great.

Are you running the latest update of the requests module? I did not encounter this error on my Mac.

https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py

Anyways, I updated the webclient.py to use posts when required.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 21-Jan-2013, at 11:16 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

Had to change the update() method to use both params and data arguments, and the requests module under both mac and windows didn't seem to fill in the POST request body. Finally got it all to work under linux.

def request(server, params=None, data=None):
    global sid
    
    if not sid: login()
    
    response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)


Thanks for the suggestions.

- j


On Monday, January 21, 2013 3:30:54 PM UTC+1, rushabh wrote:
Jonathan,

Your second approach is correct. You need to do a POST. You are not able send 2 items because of the URL limit in GET.

From the traceback, the parameters are not getting mapped correctly - can you debug the POST a bit?

I am sure you are pretty close to the solution.

best,
Rushabh



Hi.  I am still unable to get update to work and am asking two specific questions.

1. We have a BOM doctype which contains a number of individual BOM Item doctypes. Is it possible to read and update an individual BOM Item from a BOM doctype, or must one read the entire BOM and update the whole thing at once? So far I have only managed to read the entire BOM, but not an individual BOM Item.

2: Since I cannot so far read individual BOM Items, I am trying to update the entire BOM doctype. My update script works successfully if the BOM contains only a single BOM Item, but fails if there are two BOM Items. Why is that?

My script uses the same functions for get_doc(), login(), update(), etc. that you posted here: https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py. In the original update function, the doclist is added to the params argument of requests.post(), which means the entire doclist is added to the request url. Specifically, I am doing the following:

doc = get_doc("BOM", bom)
rows = doc.json().get("message")
for row in rows
# change Qty if a certain condition is met
update(rows)

If there is one BOM Item in the BOM, the update is successful.  With two or more Bom Items, I get the following traceback:

Traceback (most recent call last):
  File "...\updateqty.py", line 187, in <module>
    main()
  File "...\updateqty.py", line 182, in main
    update(server, rows);
  File "...\updateqty.py", line 50, in update
    "doclist": json.dumps(doclist)
  File "...\updateqty.py", line 62, in request
    response = requests.post(server, cookies = {"sid": sid}, params=params)
  File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
    return request('post', url, data=data, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 222, in send
    r.content
  File "C:\Python27\lib\site-packages\requests\models.py", line 550, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "C:\Python27\lib\site-packages\requests\models.py", line 496, in generate
    chunk = self.raw.read(chunk_size)
  File "C:\Python27\lib\site-packages\requests\packages\urllib3\response.py", line 148, in read
    return self._fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 561, in read
    s = self.fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 1298, in read
    return s + self._file.read(amt - len(s))
  File "C:\Python27\lib\socket.py", line 380, in read
    data = self._sock.recv(left)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

If instead I try to extend the update to use the "data" argument (which puts the data into the body of the post rather than the url), something like:

response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)

where params= {
"cmd": "webnotes.client.save"
}
and data= {
"doclist": json.dumps(doclist) 
}

I get the following result from ERPNext:

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n    execute_cmd(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 191, in execute_cmd\\n    ret = call(method, webnotes.form_dict)\\n  File \\"../lib/webnotes/handler.py\\", line 210, in call\\n    return fn(**newargs)\\n TypeError: save() takes exactly 1 argument (0 given)\\n"'}

Can you suggest the right approach for updating either individual BOM Items or the entire BOM?

Thank you for your help.


 
Jonathan,

The way to do this would be to first get, update and push.

You can send the list of dicts (we call it a doclist) via a POST request. It should work - where are you getting stuck? Is there a specific error message?

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 17-Jan-2013, at 12:49 AM, Jonathan <ir...@gmail.com> wrote:

Thanks for the reply. What we are trying to do is update a complex doctype from a script--specifically we are trying to update a BOM--that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.

The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn't get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module.  Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/BiY2q-sq-2gJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/NDrHqRjqDQEJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To post to this group, send email to er...@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

 

 

Hi Rushabh,


I have updated all the scripts, but I am happy enough if it all works under Linux.

Would it be possible to have a generalization of get_doc along the following lines:

def get_doc(server, doctype, name, value):
    return request(server, { “cmd”:“webnotes.client.get”, “doctype”:doctype, name:value})

because, for example for retrieving a sales order, I may know the purchase order number but not the sales order name.

Thanks.

- j





Jonathan,

Great.

Are you running the latest update of the requests module? I did not encounter this error on my Mac.


Anyways, I updated the webclient.py to use posts when required.

best,
Rushabh



W: https://erpnext.com
T: @rushabh_mehta

On 21-Jan-2013, at 11:16 PM, Jonathan <ir...@gmail.com> wrote:

Hi Rushabh,

Had to change the update() method to use both params and data arguments, and the requests module under both mac and windows didn't seem to fill in the POST request body. Finally got it all to work under linux.

def request(server, params=None, data=None):
    global sid
    
    if not sid: login()
    
    response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)


Thanks for the suggestions.

- j


On Monday, January 21, 2013 3:30:54 PM UTC+1, rushabh wrote:
Jonathan,

Your second approach is correct. You need to do a POST. You are not able send 2 items because of the URL limit in GET.

From the traceback, the parameters are not getting mapped correctly - can you debug the POST a bit?

I am sure you are pretty close to the solution.

best,
Rushabh



Hi.  I am still unable to get update to work and am asking two specific questions.

1. We have a BOM doctype which contains a number of individual BOM Item doctypes. Is it possible to read and update an individual BOM Item from a BOM doctype, or must one read the entire BOM and update the whole thing at once? So far I have only managed to read the entire BOM, but not an individual BOM Item.

2: Since I cannot so far read individual BOM Items, I am trying to update the entire BOM doctype. My update script works successfully if the BOM contains only a single BOM Item, but fails if there are two BOM Items. Why is that?

My script uses the same functions for get_doc(), login(), update(), etc. that you posted here: https://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py. In the original update function, the doclist is added to the params argument of requests.post(), which means the entire doclist is added to the request url. Specifically, I am doing the following:

doc = get_doc("BOM", bom)
rows = doc.json().get("message")
for row in rows
# change Qty if a certain condition is met
update(rows)

If there is one BOM Item in the BOM, the update is successful.  With two or more Bom Items, I get the following traceback:

Traceback (most recent call last):
  File "...\updateqty.py", line 187, in <module>
    main()
  File "...\updateqty.py", line 182, in main
    update(server, rows);
  File "...\updateqty.py", line 50, in update
    "doclist": json.dumps(doclist)
  File "...\updateqty.py", line 62, in request
    response = requests.post(server, cookies = {"sid": sid}, params=params)
  File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
    return request('post', url, data=data, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 374, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 222, in send
    r.content
  File "C:\Python27\lib\site-packages\requests\models.py", line 550, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "C:\Python27\lib\site-packages\requests\models.py", line 496, in generate
    chunk = self.raw.read(chunk_size)
  File "C:\Python27\lib\site-packages\requests\packages\urllib3\response.py", line 148, in read
    return self._fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 561, in read
    s = self.fp.read(amt)
  File "C:\Python27\lib\httplib.py", line 1298, in read
    return s + self._file.read(amt - len(s))
  File "C:\Python27\lib\socket.py", line 380, in read
    data = self._sock.recv(left)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

If instead I try to extend the update to use the "data" argument (which puts the data into the body of the post rather than the url), something like:

response = requests.post(server, cookies = {"sid": sid}, params=params, data=data)

where params= {
"cmd": "webnotes.client.save"
}
and data= {
"doclist": json.dumps(doclist) 
}

I get the following result from ERPNext:

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n    execute_cmd(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 191, in execute_cmd\\n    ret = call(method, webnotes.form_dict)\\n  File \\"../lib/webnotes/handler.py\\", line 210, in call\\n    return fn(**newargs)\\n TypeError: save() takes exactly 1 argument (0 given)\\n"'}

Can you suggest the right approach for updating either individual BOM Items or the entire BOM?

Thank you for your help.


 
Jonathan,

The way to do this would be to first get, update and push.

You can send the list of dicts (we call it a doclist) via a POST request. It should work - where are you getting stuck? Is there a specific error message?

- Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 17-Jan-2013, at 12:49 AM, Jonathan <ir...@gmail.com> wrote:

Thanks for the reply. What we are trying to do is update a complex doctype from a script--specifically we are trying to update a BOM--that is to say, update some subset of BOM Items for a given BOM. The first approach was to try get_doc on an individual BOM Item, passing in the parent BOM name and the item_code of the particular Bom Item as parameters. Various experiments along those lines got us the response that get takes 2 arguments and only 1 is given.

The next approach was to read the entire BOM using get_doc (this works fine), modify the fields in question, then call update. But this puts the entire pile of json into the url. Experiments trying to move the data into the body of the POST didn't get anywhere.

Can you suggest a way forward?

Thanks very much.

- j

On Saturday, January 12, 2013 4:28:50 AM UTC+1, rushabh wrote:
Jonathan, you have to "get" the customer after save, rename it and save gain. The system will only save if the incoming record's "modified" property matches with the one in the database to maintain version conflicts.

Sent from mobile

On 12-Jan-2013, at 12:00 AM, Jonathan <ir...@gmail.com> wrote:

Hi, sorry, me again.

We are trying to create--and optionally update--a Customer doctype based on the script that started this thread.  We are able to create a customer, but so far we have not been able to create a customer where the customer_name is different from the name.  In other words we have a unique name for the Customer ("johndoe123"), which is what we want the doctype to be referenced by, but we want the customer's name to be "John Doe". Once the Customer doctype is created we can change the customer name using the ERPNext API, but we were unable to create the customer that way or update it thereafter. In particular, the update function returns a message that says "Document has been modified after you have opened it."

Could you point us in the right direction?

Thanks.

On Monday, January 7, 2013 3:47:39 PM UTC+1, Jonathan wrote:
Thanks for the suggestion. The problem seems to be the weird parameter-doubling from the 'requests' module.  Now the login is working...

- j

On Monday, January 7, 2013 3:19:45 PM UTC+1, rushabh wrote:
The test runs fine on my setup. I think your installation may be messed up.

What do you get when you run that from the browser?

Sent from mobile

On 07-Jan-2013, at 7:32 PM, Jonathan <ir...@gmail.com> wrote:

Here's the redacted url returned from response.get().  Odd that all the params are doubled.

https://{server}/server.py?pwd={password}&cmd=login&usr={user}&pwd={password}&cmd=login&usr={user}

We are using the sample code llinked to earlier in the forum, only changing the server, user, and password parameters at the top (we also changed response.json.get() to response.json().get()--the code wouldn't work otherwise).

Thanks.

On Monday, January 7, 2013 2:43:00 PM UTC+1, rushabh wrote:
Can you post the entire url? I think you need to pass login id and password as the url parameters

For example you can login via:

server.py?cmd=login&usr=Administrator&pwd=admin

If you are passwords are correctly set.


On Mon, Jan 7, 2013 at 6:40 PM, Amin Zayani <za...@gmail.com> wrote:
Thanks for the quick reply.  We should have thought to test the simplest server.py url. We get back the following json in response to the login.

{u'message': u'', u'exc': u'"Traceback (innermost last):\\n  File \\"../lib/webnotes/handler.py\\", line 159, in handle\\n execute_cmd(cmd)\\n  Fil
e \\"../lib/webnotes/handler.py\\", line 176, in execute_cmd\\n method = get_method(cmd)\\n  File \\"../lib/webnotes/handler.py\\", line 218, in ge
t_method\\n    method = globals()[cmd]\\n KeyError: u\\"[\'login\', \'login\']\\"\\n"'}

Any suggestions?

Thanks again.

PS: my colleague Jonathan will join this thread

On Monday, January 7, 2013 1:10:56 PM UTC+1, rushabh wrote:
Amin,

Thanks for making the 3rd party API script available. We are newbies at ERPNext, so please excuse the following questions if the answers should be obvious.

In our tests using the sample code fromhttps://github.com/webnotes/wnframework/blob/master/webnotes/utils/webclient.py, we have not been able to get past login--we get a 404 response.  We are trying variations of "http://{our local erpnext server}/webnotes/erpnext_master/public/server.py" as the server address.  Our ERPNext is installed simply on a Ubuntu 12.10 virtual machine on a local server and is also accessible outside our LAN through a subdomain of our site, so we were trying, for example, "http://{our local erpnext server}/public/server.py". Can you give us any hints about what the url should be? (We also tried "client.py" instead of "server.py").

Don't use /public/server.py --- just use {local erpnext server}/server.py

Since all requests are passed via server.py (and this should be accessible via your browser). So set "server" to that url (which is server.py replaced by app.html)

We are also not entirely certain that we have updated ERPNext correctly in order to install the correct "client.py" file into the proper location. Can you tell us how to ascertain whether we have the correct file and it's in the expected place?  Once it's in the right place do we need to set any permissions? (because the repository updated is webnotes framework and we only update our ERPNext repository version)

the webclient.py file can be anywhere because it accesses the system via http requests.

Also webclient.py is a template and you can use that code to access data from anywhere.


Thanks.

On Monday, January 7, 2013 6:08:22 AM UTC+1, rushabh wrote:


On Mon, Jan 7, 2013 at 10:32 AM, Rushabh Mehta <rm...@gmail.com> wrote:
Just updated client.py with

webnotes.client.get

pass "doctype" and "name" as parameters

example:

cmd=webnotes.client.get&doctype=[doctype]&name=[name]

you will get a JSON object with a list of main record and the child records (if any)


On Fri, Jan 4, 2013 at 7:42 PM, Amin Zayani <za...@gmail.com> wrote:
Great!
Any chance you add a "read" method to fetch data from ERPNext? And include a simple example for fetching some doctype?

Thanks

On Wednesday, December 19, 2012 12:41:39 PM UTC+1, rushabh wrote:
Dear all,

Since there has been some interest off and on for this, I have created a very alpha level script for those who are interested to integrate other 3rd party tools into ERPNext.

The schematics are very simple and the script is pretty self-expalnatory.


Please ping us on the Developer Forum if you have any difficulty. If you are able to integrate any app, please share with us so other users can also benefit.

best,
Rushabh



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/yzLMPR9UcxsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 








Twitter: @rushabh_mehta



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+unsubscr…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/QpP1CwrCuW8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9sfw-iCSHTkJ.


For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta



You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/AtBNp4DGZjsJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/d1YRSsSA8U8J.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/sso_-D03AMEJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to er…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/BiY2q-sq-2gJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 





You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

To post to this group, send email to erpnext-dev…@googlegroups.com.

To unsubscribe from this group, send email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/NDrHqRjqDQEJ.

For more options, visit https://groups.google.com/groups/opt_out.

 

 




You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

To post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/hwlxXe3VleYJ.

For more options, visit https://groups.google.com/groups/opt_out.