How do i upload an image in PO as a document using Python

How do i upload an image in PO as a document using Python

Hi,

I am trying to upload an image document in the Zoho books purchase order module but the script is not working.

Python script as Follows: 

  1. #
    #
    #   Image Capture Start
    #
    #

    app = xw.App(visible=True, add_book=False)
    wb = app.books.open(r'C:\Users\Bhavik\OneDrive\Documents\Urban Utility\PO & Bills.xlsx') # Open file
    sheet = wb.sheets('Sheet1') # selected sheet
    all = sheet.used_range # Get content range
    all.api.CopyPicture() # Copy picture area
    sheet.api.Paste() # Paste
    img_name = 'PO_Bill'
    pic = sheet.pictures[0] # Current picture
    pic.api.Copy() # Copy the picture
    img = ImageGrab.grabclipboard() # Get the picture data of the clipboard
    img.save("C:\\Users\\Bhavik\\OneDrive\\Documents\\Urban Utility\\"+img_name + ".png") # Save the picture
    pic.delete() # Delete sheet Pictures on
    wb.close() # Do not save , Direct closure
    app.quit()

    # Read Image
    # read an image
    # screenShot = iio.imread(r'C:\Users\Bhavik\OneDrive\Documents\Urban Utility\PO_Bill.png')
    screenShot = open(r'C:\Users\Bhavik\OneDrive\Documents\Urban Utility\PO_Bill.png','r').read
    screenS = str(r'C:\Users\Bhavik\OneDrive\Documents\Urban Utility\PO_Bill.png')
    # screenShot = Image(url=screenS)
    print(screenS)
    #
    #
    #   Image Capture End
    #
    # # Data to be pushed
    sku = obj_Json['SKU']
        item_id = ''
        supplier = obj_Json['Supplier Zoho']
        contact_id = ''
        reference_number = str(obj_Json['Order Number'])
        quantity = obj_Json['Quantity']
        rate = obj_Json['Price per pcs RMB']
        branch_id = '2486101000005206845'
        warehouse_id = '2486101000000107255'
        currency_id = '2486101000000000113'
        exchange_rate = 0.6
        total_amount = obj_Json['Total Amount']
        order_date = date.today()
        zoho_cost = obj_Json['Zoho Cost']
        account_id = '2486101000009226813'
        china_Frieght = obj_Json['China Freight'] # JSON Object
    # PO Array
        line_item_obj=[]
        line_item_array = {'item_id' : item_id,
                            'warehouse_id':warehouse_id,
                            'quantity' : quantity,
                            'rate' : rate}
        line_item_obj.append(line_item_array)
        document_obj = []
        document_array = {'file_name': screenS,
                            'file_type':'png',
                            'document_id':0}
        document_obj.append(document_array)
        json_array = {'line_items' : line_item_obj,
                        'vendor_id': contact_id,
                        'exchange_rate': exchange_rate,
                        'date': order_date,
                        'tax_treatment': tax_treatment,
                        'branch_id': branch_id,
                        'reference_number':reference_number,
                        'currency_id':currency_id,
                        'documents':document_obj}
        json_obj = json.dumps(json_array,default=str)





                            Zoho Desk Resources

                            • Desk Community Learning Series


                            • Digest


                            • Functions


                            • Meetups


                            • Kbase


                            • Resources


                            • Glossary


                            • Desk Marketplace


                            • MVP Corner


                            • Word of the Day



                                Zoho Marketing Automation


                                        Manage your brands on social media



                                              Zoho TeamInbox Resources

                                                Zoho DataPrep Resources



                                                  Zoho CRM Plus Resources

                                                    Zoho Books Resources


                                                      Zoho Subscriptions Resources

                                                        Zoho Projects Resources


                                                          Zoho Sprints Resources


                                                            Qntrl Resources


                                                              Zoho Creator Resources


                                                                Zoho WorkDrive Resources



                                                                  Zoho Campaigns Resources

                                                                    Zoho CRM Resources

                                                                    • CRM Community Learning Series

                                                                      CRM Community Learning Series


                                                                    • Tips

                                                                      Tips

                                                                    • Functions

                                                                      Functions

                                                                    • Meetups

                                                                      Meetups

                                                                    • Kbase

                                                                      Kbase

                                                                    • Resources

                                                                      Resources

                                                                    • Digest

                                                                      Digest

                                                                    • CRM Marketplace

                                                                      CRM Marketplace

                                                                    • MVP Corner

                                                                      MVP Corner

                                                                    





                                                                    




                                                                        Design. Discuss. Deliver.

                                                                        Create visually engaging stories with Zoho Show.

                                                                        Get Started Now