<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Fabric API - Spark Library Upload Staging Library in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-API-Spark-Library-Upload-Staging-Library/m-p/4274169#M5063</link>
    <description>&lt;P&gt;Hi Yang,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to get it working using this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;headers = {
    'Authorization': f"Bearer {token}"
    #It worked with no other headers

}


url = 'https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/environments/{environment_id}/staging/libraries'
file_path = "file_path"

with open(file_path,'rb') as file:
        
    files = {'file':(os.path.basename(file_path),file)}
    response = requests.post(url,files=files,
                             headers = headers)
    
if response.status_code == 200:
    print(f'Success: {response.json}')
else:
    print(f'Failure: {response.status_code} {response.text}')&lt;/LI-CODE&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
    <pubDate>Thu, 07 Nov 2024 14:05:06 GMT</pubDate>
    <dc:creator>jaskiea</dc:creator>
    <dc:date>2024-11-07T14:05:06Z</dc:date>
    <item>
      <title>Fabric API - Spark Library Upload Staging Library</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-API-Spark-Library-Upload-Staging-Library/m-p/4271503#M5014</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble with this endpoint. I am able to authenticate but having no luck with sending up a .whl file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep getting this error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"EnvironmentValidationFailed","message":"Invalid request. Provide a library with a valid format such as .jar, .py, .whl, .tar.gz, or environment.yml."&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using python w/requests, I feel like it could be something simple with how I am sending the file or maybe with my headers?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 00:25:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-API-Spark-Library-Upload-Staging-Library/m-p/4271503#M5014</guid>
      <dc:creator>jaskiea</dc:creator>
      <dc:date>2024-11-06T00:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: Fabric API - Spark Library Upload Staging Library</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-API-Spark-Library-Upload-Staging-Library/m-p/4271552#M5016</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/680518"&gt;@jaskiea&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error message indicates that the request is invalid, please provide the file in the correct format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following suggestions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Make sure that the uploaded file is indeed a .whl file and that it is not corrupted. The API supports .jar, .py, .whl, .tar.gz, or environment.yml formats.&lt;/LI&gt;
&lt;LI&gt;The maximum allowed request size is 100MB. make sure your files do not exceed this limit.&lt;/LI&gt;
&lt;LI&gt;Sometimes network problems can affect this, so please make sure you have a stable internet connection.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an official document you can refer to that may help:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/rest/api/fabric/environment/spark-libraries/upload-staging-library?tabs=HTTP" target="_blank"&gt;Spark Libraries - Upload Staging Library - REST API (Environment) | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 01:32:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-API-Spark-Library-Upload-Staging-Library/m-p/4271552#M5016</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-06T01:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Fabric API - Spark Library Upload Staging Library</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-API-Spark-Library-Upload-Staging-Library/m-p/4272570#M5041</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes I made sure it was a legitamate whl file, I also tried a simple .py file and that failed the validation as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am still wondering if there could be a simple issue with how I am sending the request.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;headers = {
    'Authorization': f"Bearer {token}"
    ,'Content-Type':'multipart/form-data'

}


url = 'https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/environments/{environment_id}/staging/libraries'
file_path = "file_path"

with open(file_path,'rb') as file:
        
    files = {'file':file}
    response = requests.post(url,files=files,
                             headers = headers)
    
if response.status_code == 200:
    print(f'Success: {response.json}')
else:
    print(f'Failure: {response.status_code} {response.text}')&lt;/LI-CODE&gt;&lt;P&gt;Here's my code. I have tested other environment call and authentication works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Adam&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 13:39:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-API-Spark-Library-Upload-Staging-Library/m-p/4272570#M5041</guid>
      <dc:creator>jaskiea</dc:creator>
      <dc:date>2024-11-06T13:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: Fabric API - Spark Library Upload Staging Library</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-API-Spark-Library-Upload-Staging-Library/m-p/4273543#M5058</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/680518"&gt;@jaskiea&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;import requests

headers = {
'Authorization': f"Bearer {token}",
'Content-Type': 'multipart/form-data',
'Content-Length': str(os.path.getsize(file_path)) # Add Content-Length header
}

url = 'https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/environments/{environment_id}/staging/libraries'
file_path = "file_path"

with open(file_path, 'rb') as file:
files = {'file': (os.path.basename(file_path), file)} # Add filename
response = requests.post(url, files=files, headers=headers)

if response.status_code == 200:
print(f'Success: {response.json()}')
else:
print(f'Failure: {response.status_code} {response.text}')&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add Content-Length to the original code to specify the file size, added filename.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have any other questions please feel free to contact me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 07:06:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-API-Spark-Library-Upload-Staging-Library/m-p/4273543#M5058</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-07T07:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Fabric API - Spark Library Upload Staging Library</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-API-Spark-Library-Upload-Staging-Library/m-p/4274169#M5063</link>
      <description>&lt;P&gt;Hi Yang,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to get it working using this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;headers = {
    'Authorization': f"Bearer {token}"
    #It worked with no other headers

}


url = 'https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/environments/{environment_id}/staging/libraries'
file_path = "file_path"

with open(file_path,'rb') as file:
        
    files = {'file':(os.path.basename(file_path),file)}
    response = requests.post(url,files=files,
                             headers = headers)
    
if response.status_code == 200:
    print(f'Success: {response.json}')
else:
    print(f'Failure: {response.status_code} {response.text}')&lt;/LI-CODE&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 14:05:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-API-Spark-Library-Upload-Staging-Library/m-p/4274169#M5063</guid>
      <dc:creator>jaskiea</dc:creator>
      <dc:date>2024-11-07T14:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Fabric API - Spark Library Upload Staging Library</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-API-Spark-Library-Upload-Staging-Library/m-p/4274770#M5074</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/680518"&gt;@jaskiea&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am glad to hear that your problem has been resolved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am very thankful to you for sharing your solution which will be of great help to other users who are experiencing similar issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please mark this helpful post as “Answered”?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your cooperation!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2024 01:36:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-API-Spark-Library-Upload-Staging-Library/m-p/4274770#M5074</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-08T01:36:40Z</dc:date>
    </item>
  </channel>
</rss>

