(Restful API) Help me to write code for HTTP Post/Get

Hi all,
 
1. I wrote a python code for login using Post and here is the  link of my code http://pastiebin.com/53bbce75204fc . When i execute this code it will give output as  {"message":"Logged In","full_name":"Administrator"}. I think it is right as given in https://frappe.io/apps/frappe-framework/developers/api/rest_api.
2. After that i tried above with ruby code ie http://pastiebin.com/53bbd0729431c it gives output like usr=Administrator&pwd=admin
{"message":"Logged In","full_name":"Administrator"}
200
3. After that i tried to Post the reorder quantity(re_order_qty) for a particular item(in ruby)  and here is the link of my code http://pastiebin.com/53bbd20f59ce8. When i execute this code it will give out put as usr=Administrator&pwd=admin
{"message":"Logged In","full_name":"Administrator"}
200
email_id=sam_sd%40gmail.com
{}
200

In the above out put i not received any response(the response field is empty {}). I tried this in python code also and i found the out put as {}. Here is the link of my python code http://pastiebin.com/53bbd398d84c4 .
4. How to get the response of my code to know that Post operation successful. Please help me to write code for that.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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 view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/c6c4c953-fe20-4bbd-b622-5c2c97d110ca%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
The login method takes as form data the user and the password, whereas the resource takes a dict named data as parameter


The proper way should be to send as form data :
{
data : {
       //Your data
    }
}


Also POST request are for creating document. So you shouldn't send a name to the document (LEAD0006)
If you're trying to fetch the document send a GET request.



Le mardi 8 juillet 2014 13:22:19 UTC+2, rahul nejanawar a écrit :
Hi all,
 
1. I wrote a python code for login using Post and here is the  link of my code http://pastiebin.com/53bbce75204fc . When i execute this code it will give output as  {"message":"Logged In","full_name":"Administrator"}. I think it is right as given in https://frappe.io/apps/frappe-framework/developers/api/rest_api.
2. After that i tried above with ruby code ie http://pastiebin.com/53bbd0729431c it gives output like usr=Administrator&pwd=admin
{"message":"Logged In","full_name":"Administrator"}
200
3. After that i tried to Post the reorder quantity(re_order_qty) for a particular item(in ruby)  and here is the link of my code http://pastiebin.com/53bbd20f59ce8. When i execute this code it will give out put as usr=Administrator&pwd=admin
{"message":"Logged In","full_name":"Administrator"}
200
email_id=sam_sd%40gmail.com
{}
200

In the above out put i not received any response(the response field is empty {}). I tried this in python code also and i found the out put as {}. Here is the link of my python code http://pastiebin.com/53bbd398d84c4 .
4. How to get the response of my code to know that Post operation successful. Please help me to write code for that.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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 view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/e9075b44-2b7f-4a83-b0f2-e0dc77f63e7b%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
Thank you hassan,

Here I tried Get  http://pastiebin.com/53bc058a14df3 but I m getting 403 error by executing this code. So please correct me I m new to erpnext. And also please give me some examples for Post/Get.  

On Tuesday, July 8, 2014 6:35:23 PM UTC+5:30, hassan bellounis wrote:
The login method takes as form data the user and the password, whereas the resource takes a dict named data as parameter


The proper way should be to send as form data :
{
data : {
       //Your data
    }
}


Also POST request are for creating document. So you shouldn't send a name to the document (LEAD0006)
If you're trying to fetch the document send a GET request.



Le mardi 8 juillet 2014 13:22:19 UTC+2, rahul nejanawar a écrit :
Hi all,
 
1. I wrote a python code for login using Post and here is the  link of my code http://pastiebin.com/53bbce75204fc . When i execute this code it will give output as  {"message":"Logged In","full_name":"Administrator"}. I think it is right as given in https://frappe.io/apps/frappe-framework/developers/api/rest_api.
2. After that i tried above with ruby code ie http://pastiebin.com/53bbd0729431c it gives output like usr=Administrator&pwd=admin
{"message":"Logged In","full_name":"Administrator"}
200
3. After that i tried to Post the reorder quantity(re_order_qty) for a particular item(in ruby)  and here is the link of my code http://pastiebin.com/53bbd20f59ce8. When i execute this code it will give out put as usr=Administrator&pwd=admin
{"message":"Logged In","full_name":"Administrator"}
200
email_id=sam_sd%40gmail.com
{}
200

In the above out put i not received any response(the response field is empty {}). I tried this in python code also and i found the out put as {}. Here is the link of my python code http://pastiebin.com/53bbd398d84c4 .
4. How to get the response of my code to know that Post operation successful. Please help me to write code for that.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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 view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8a8b347d-af74-478c-9821-2e2d0ba395a0%40googlegroups.com.

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


On 08-Jul-2014, at 8:25 pm, rahul nejanawar <ra...@gmail.com> wrote:

Thank you hassan,

Here I tried Get  http://pastiebin.com/53bc058a14df3 but I m getting 403 error by executing this code. So please correct me I m new to erpnext. And also please give me some examples for Post/Get.  



On Tuesday, July 8, 2014 6:35:23 PM UTC+5:30, hassan bellounis wrote:
The login method takes as form data the user and the password, whereas the resource takes a dict named data as parameter


The proper way should be to send as form data :
{
data : {
       //Your data
    }
}


Also POST request are for creating document. So you shouldn't send a name to the document (LEAD0006)
If you're trying to fetch the document send a GET request. 



Le mardi 8 juillet 2014 13:22:19 UTC+2, rahul nejanawar a écrit :
Hi all,
 
1. I wrote a python code for login using Post and here is the  link of my code http://pastiebin.com/53bbce75204fc . When i execute this code it will give output as  {"message":"Logged In","full_name":"Administrator"}. I think it is right as given in https://frappe.io/apps/frappe-framework/developers/api/rest_api.
2. After that i tried above with ruby code ie http://pastiebin.com/53bbd0729431c it gives output likeusr=Administrator&pwd=admin
{"message":"Logged In","full_name":"Administrator"}
200
3. After that i tried to Post the reorder quantity(re_order_qty) for a particular item(in ruby)  and here is the link of my code http://pastiebin.com/53bbd20f59ce8. When i execute this code it will give out put as usr=Administrator&pwd=admin
{"message":"Logged In","full_name":"Administrator"}
200
email_id=sam_sd%40gmail.com
{}
200

In the above out put i not received any response(the response field is empty {}). I tried this in python code also and i found the out put as {}. Here is the link of my python code http://pastiebin.com/53bbd398d84c4 .
4. How to get the response of my code to know that Post operation successful. Please help me to write code for that.


-- 
Note:
 
If you are posting an issue,
1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8a8b347d-af74-478c-9821-2e2d0ba395a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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 view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/E1594F51-17C6-4821-AEBB-BEF9B8F0F8FC%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.
Thank you rushabh for the link,
I used frappeclient.py to do a simple GET for an Item. (Note: I already had an item name 'Plywood' in my localhost ERPNext installation. So I am trying to get this.)

Please find my code in the below link. The code has two parts (1) FrappeClient (2) our code using the client to do a GET. To look at my code (2), please scroll down to the bottom.

My code when run, responds with code 403. Also a server traceback which you can find in http://pastie.org/9371349

Appreciate if someone could look into my code and let me know what is the mistake.

On Wednesday, July 9, 2014 10:53:13 AM UTC+5:30, rushabh wrote:


On 08-Jul-2014, at 8:25 pm, rahul nejanawar <ra...@gmail.com> wrote:

Thank you hassan,

Here I tried Get  http://pastiebin.com/53bc058a14df3 but I m getting 403 error by executing this code. So please correct me I m new to erpnext. And also please give me some examples for Post/Get.  



On Tuesday, July 8, 2014 6:35:23 PM UTC+5:30, hassan bellounis wrote:
The login method takes as form data the user and the password, whereas the resource takes a dict named data as parameter


The proper way should be to send as form data :
{
data : {
       //Your data
    }
}


Also POST request are for creating document. So you shouldn't send a name to the document (LEAD0006)
If you're trying to fetch the document send a GET request. 



Le mardi 8 juillet 2014 13:22:19 UTC+2, rahul nejanawar a écrit :
Hi all,
 
1. I wrote a python code for login using Post and here is the  link of my code http://pastiebin.com/53bbce75204fc . When i execute this code it will give output as  {"message":"Logged In","full_name":"Administrator"}. I think it is right as given in https://frappe.io/apps/frappe-framework/developers/api/rest_api.
2. After that i tried above with ruby code ie http://pastiebin.com/53bbd0729431c it gives output likeusr=Administrator&pwd=admin
{"message":"Logged In","full_name":"Administrator"}
200
3. After that i tried to Post the reorder quantity(re_order_qty) for a particular item(in ruby)  and here is the link of my code http://pastiebin.com/53bbd20f59ce8. When i execute this code it will give out put as usr=Administrator&pwd=admin
{"message":"Logged In","full_name":"Administrator"}
200
email_id=sam_sd%40gmail.com
{}
200

In the above out put i not received any response(the response field is empty {}). I tried this in python code also and i found the out put as {}. Here is the link of my python code http://pastiebin.com/53bbd398d84c4 .
4. How to get the response of my code to know that Post operation successful. Please help me to write code for that.


-- 
Note:
 
If you are posting an issue,
1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8a8b347d-af74-478c-9821-2e2d0ba395a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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 view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/b90253b8-de3d-49d8-9a49-19f2197b0f4d%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
Looks like you are not passing cookies correctly


On 09-Jul-2014, at 5:48 pm, rahul nejanawar <ra...@gmail.com> wrote:

Thank you rushabh for the link,
I used frappeclient.py to do a simple GET for an Item. (Note: I already had an item name 'Plywood' in my localhost ERPNext installation. So I am trying to get this.)

Please find my code in the below link. The code has two parts (1) FrappeClient (2) our code using the client to do a GET. To look at my code (2), please scroll down to the bottom.

My code when run, responds with code 403. Also a server traceback which you can find in http://pastie.org/9371349

Appreciate if someone could look into my code and let me know what is the mistake.

On Wednesday, July 9, 2014 10:53:13 AM UTC+5:30, rushabh wrote:


On 08-Jul-2014, at 8:25 pm, rahul nejanawar <ra...@gmail.com> wrote:

Thank you hassan,

Here I tried Get  http://pastiebin.com/53bc058a14df3 but I m getting 403 error by executing this code. So please correct me I m new to erpnext. And also please give me some examples for Post/Get.  



On Tuesday, July 8, 2014 6:35:23 PM UTC+5:30, hassan bellounis wrote:
The login method takes as form data the user and the password, whereas the resource takes a dict named data as parameter


The proper way should be to send as form data :
{
data : {
       //Your data
    }
}


Also POST request are for creating document. So you shouldn't send a name to the document (LEAD0006)
If you're trying to fetch the document send a GET request. 



Le mardi 8 juillet 2014 13:22:19 UTC+2, rahul nejanawar a écrit :
Hi all,
 
1. I wrote a python code for login using Post and here is the  link of my code http://pastiebin.com/53bbce75204fc . When i execute this code it will give output as  {"message":"Logged In","full_name":"Administrator"}. I think it is right as given in https://frappe.io/apps/frappe-framework/developers/api/rest_api.
2. After that i tried above with ruby code ie http://pastiebin.com/53bbd0729431c it gives output likeusr=Administrator&pwd=admin
{"message":"Logged In","full_name":"Administrator"}
200
3. After that i tried to Post the reorder quantity(re_order_qty) for a particular item(in ruby)  and here is the link of my code http://pastiebin.com/53bbd20f59ce8. When i execute this code it will give out put as usr=Administrator&pwd=admin
{"message":"Logged In","full_name":"Administrator"}
200
email_id=sam_sd%40gmail.com
{}
200

In the above out put i not received any response(the response field is empty {}). I tried this in python code also and i found the out put as {}. Here is the link of my python code http://pastiebin.com/53bbd398d84c4 .
4. How to get the response of my code to know that Post operation successful. Please help me to write code for that.


-- 
Note:
 
If you are posting an issue,
1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
--- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8a8b347d-af74-478c-9821-2e2d0ba395a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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 view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/b90253b8-de3d-49d8-9a49-19f2197b0f4d%40googlegroups.com.

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



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    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 view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/C2B221A6-2C82-44FF-BD4F-BCB91DE8A978%40gmail.com.

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