Forum Discussion
404 error client error - post /imports power bi api
- 1 year ago
Hi Anonymous ,
Thank you for the update.
Power BI may redirect requests to a regional cluster e.g., wabi-west-us-redirect.analysis.windows.net. While your code attempts to follow this redirect manually, it's important to note that Spring’s RestTemplate does not automatically follow redirects for POST requests. Therefore, you should extract the redirected URL from the initial 307 Temporary Redirect response and use it as the actual import endpoint for subsequent requests.
The InvalidFileSizeError with a reported size of 9223372036854775807 indicates that the file size is not being correctly read. This issue often arises when using FileSystemResource. To avoid this, use ByteArrayResource instead, which ensures accurate file size detection and avoids compatibility issues with the Power BI API.
Do not manually set the Content-Type header to multipart/form-data. Doing so can interfere with the automatic generation of multipart boundaries, which are essential for properly formatting the request. Let RestTemplate handle this header internally when constructing the multipart request.
To isolate whether the issue lies within your code or the API itself, replicate the same request using Postman. Ensure you use the correct endpoint, headers, and file upload configuration. Additionally, enable detailed HTTP logging in your Spring Boot application to inspect the raw request being sent. This can help identify any misconfigurations in headers, body formatting, or endpoint construction.
Hope this helps.
Warm Regards,
Chaithra E
Hi Anonymous ,
Thank you for the update.
Power BI may redirect requests to a regional cluster e.g., wabi-west-us-redirect.analysis.windows.net. While your code attempts to follow this redirect manually, it's important to note that Spring’s RestTemplate does not automatically follow redirects for POST requests. Therefore, you should extract the redirected URL from the initial 307 Temporary Redirect response and use it as the actual import endpoint for subsequent requests.
The InvalidFileSizeError with a reported size of 9223372036854775807 indicates that the file size is not being correctly read. This issue often arises when using FileSystemResource. To avoid this, use ByteArrayResource instead, which ensures accurate file size detection and avoids compatibility issues with the Power BI API.
Do not manually set the Content-Type header to multipart/form-data. Doing so can interfere with the automatic generation of multipart boundaries, which are essential for properly formatting the request. Let RestTemplate handle this header internally when constructing the multipart request.
To isolate whether the issue lies within your code or the API itself, replicate the same request using Postman. Ensure you use the correct endpoint, headers, and file upload configuration. Additionally, enable detailed HTTP logging in your Spring Boot application to inspect the raw request being sent. This can help identify any misconfigurations in headers, body formatting, or endpoint construction.
Hope this helps.
Warm Regards,
Chaithra E