Forum Discussion
Sempy Labs : Create Shortcut
Has anyone managed to get the Sempy Labs code to work for Shortcut?
Here's my code :
And here's the error:
FabricHTTPException: 400 Bad Request for url: https://api.fabric.microsoft.com//v1/workspaces/b31d9a25-19d0-4188-a24f-a697b4b0342d/items/beb576fc-7a5a-4395-8b7b-06b863d436fb/shortcuts Error: {"requestId":"5a6bf911-027a-4cf9-b78b-2e89dd596789","errorCode":"BadRequest","moreDetails":[{"errorCode":"RequestBodyValidationFailed","message":"Target path doesn't exist"}],"message":"The request could not be processed due to missing or invalid information"} Headers: {'Cache-Control': 'no-store, must-revalidate, no-cache', 'Pragma': 'no-cache', 'Transfer-Encoding': 'chunked', 'Content-Type': 'application/json; charset=utf-8', 'x-ms-public-api-error-code': 'BadRequest', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'X-Frame-Options': 'deny', 'X-Content-Type-Options': 'nosniff', 'RequestId': '5a6bf911-027a-4cf9-b78b-2e89dd596789', 'Access-Control-Expose-Headers': 'RequestId', 'request-redirected': 'true', 'home-cluster-uri': 'https://wabi-north-europe-d-primary-redirect.analysis.windows.net/', 'Date': 'Fri, 24 Jan 2025 10:37:16 GMT'} The above exception was the direct cause of the following exception: ValueError Traceback (most recent call last) Cell In[10], line 1 ----> 1 labs.lakehouse.create_shortcut_onelake( 2 table_name="Groups", 3 source_lakehouse="011a5163-f6d2-4e5e-a11f-55e596144317", 4 source_workspace="0867c351-fc09-440d-8258-a04a8d7adcdb", 5 destination_lakehouse="beb576fc-7a5a-4395-8b7b-06b863d436fb", 6 destination_workspace="b31d9a25-19d0-4188-a24f-a697b4b0342d", 7 shortcut_name="Groups" 8 ) File /nfs4/pyenv-8a35d148-f8e8-452d-84bf-e9775b4bc282/lib/python3.11/site-packages/sempy_labs/lakehouse/_shortcuts.py:102, in create_shortcut_onelake(table_name, source_lakehouse, source_workspace, destination_lakehouse, destination_workspace, shortcut_name) 100 print(response.status_code) 101 except Exception as e: --> 102 raise ValueError( 103 f"{icons.red_dot} Failed to create a shortcut for the '{table_name}' table." 104 ) from e ValueError: 🔴 Failed to create a shortcut for the 'Groups' table.
I've found the solution to my problem, but the shortcut is created in the form of a schema in my lakehouse, whereas I want a shortcut in the form of a table in my dbo schema.
labs.lakehouse.create_shortcut_onelake(table_name="dbo/Ventes",source_lakehouse="011a5163-f6d2-4e5e-a11f-55e596144317",source_workspace="0867c351-fc09-440d-8258-a04a8d7adcdb",destination_lakehouse="beb576fc-7a5a-4395-8b7b-06b863d436fb",destination_workspace="b31d9a25-19d0-4188-a24f-a697b4b0342d",shortcut_name="Ventes")
7 Replies
- Charline_74Resolver I
I've found the solution to my problem, but the shortcut is created in the form of a schema in my lakehouse, whereas I want a shortcut in the form of a table in my dbo schema.
labs.lakehouse.create_shortcut_onelake(table_name="dbo/Ventes",source_lakehouse="011a5163-f6d2-4e5e-a11f-55e596144317",source_workspace="0867c351-fc09-440d-8258-a04a8d7adcdb",destination_lakehouse="beb576fc-7a5a-4395-8b7b-06b863d436fb",destination_workspace="b31d9a25-19d0-4188-a24f-a697b4b0342d",shortcut_name="Ventes")- luisatorresxRegular Visitor
I have the exact same issue, did you find a solution?
- nilendraFabricSuper User
Hi Charline_74
You API call code looks ok as pwer official docs“Target path doesn’t exist” error typically means the source table path or folders do not match what the API expects, so creating the shortcut fails
Lets try to debug it :
Use sempy_labs.lakehouse.get_lakehouse_tables(lakehouse=source_lakehouse, workspace=source_workspace) to list all tables and confirm the exact name shown in the "Table Name" column matches what you pass to table_nameCreate shortcut manually ,If that succeeds, note the exact path or table name used and replicate those settings in create_shortcut_onelake.
lets hope this will work .
Thanks - nilendraFabricSuper User
Hi Charline_74
Could you please share full code here. - Charline_74Resolver I
Here is all the code
%pip install semantic-link-labsimport sempy_labs as labslabs.lakehouse.create_shortcut_onelake(table_name="Ventes",source_lakehouse="011a5163-f6d2-4e5e-a11f-55e596144317",source_workspace="0867c351-fc09-440d-8258-a04a8d7adcdb",destination_lakehouse="beb576fc-7a5a-4395-8b7b-06b863d436fb",destination_workspace="b31d9a25-19d0-4188-a24f-a697b4b0342d",shortcut_name="Ventes") - AnonymousNot applicable
Hi Charline_74,
Thanks for reaching out to the Microsoft fabric community forum.
It looks like you were able to find the solution of your issue. Can you verify if you got the solution and also accept it as Solution so that other users can benefit from it. If not kindly let us know your issue.
I would also take a moment to thank nilendraFabric, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.
Community Support TeamIf this post helps then please mark it as a solution, so that other members find it more quickly.
Thank you.
- AnonymousNot applicable
Hi Charline_74,
As we haven’t heard back from you, so just following up to our previous message. I'd like to confirm if you've successfully resolved this issue or if you need further help?
If yes, you are welcome to share your workaround and mark it as a solution so that other users can benefit as well. If you find a reply particularly helpful to you, you can also mark it as a solution.
If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.
Thank you for your patience and look forward to hearing from you.