Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

HTTP 403 error

Greetings,

 

I can run the Python code in Pycharm, there are no errors.

 

import urllib.request
with urllib.request.urlopen("URL/server/rest/services/CFA_Boundaries/FeatureServer/0/?start=0&limit=50&api_token=token") as url:
data = url.read().decode("utf-8")
output = data

 

I set the Data Source settings in Global permissions.

 

When I run it from within Power BI, using the Get Data > Other > Python Script.

I get a HTTP 403 error.

 ESRIRESTURL.png

 

I would appreciate any assistance,

 

Regards,

 

Clive

3 ACCEPTED SOLUTIONS
PhilipTreacy
Super User
Super User

Hi @Anonymous 

It might be that the user agent in PBI is being blocked, or the URL is somehow being malformed inside PBI?

You could try using Fiddler to see what traffic is going between PBI and the website so you can see what PBI is sending.

https://www.telerik.com/fiddler

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

Anonymous
Not applicable

Hi Phil,

 

Thanks for the suggestion. I ran the Python script in Pycharm, that worked.

I have never used Fiddler, so wouldn't know how to link to Power BI??

 

I followed Chris Webb's Blog (https://blog.crossjoin.co.uk/2014/03/26/working-with-web-services-in-power-query/), to minimise the number of times entering the API token.

I have the Web.Contents() icon in Power BI Fields tag, but don't see the icon in the Data Sources Settings as shown in the Blog??

 

When I run the Parse JSOn option, I get DataFormat.Error:

DataFormat.Error: We found extra characters at the end of JSON input.
Details:
Value=
Position=0

 

Still can't run the REST URL??

 

 

 

View solution in original post

Hi @Anonymous ,

Have you checked the json format is valid before using it in power bi? Invalid json format could casue the data format error.

About HTTP 403 error, you can refer these simliar issues and articles:

  1. 403 Error when trying to access REST API 
  2. Power BI REST API gives 403 error (User does not have access to group) 
  3. FIX: Power BI error Access to the resource is forbidden 

 

In addition, since there is only data field in the table, could you please consider sharing some screenshots in power query about this issue?

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

6 REPLIES 6
PhilipTreacy
Super User
Super User

Hi @Anonymous 

As @v-yingjl points out, that JSON you posted isn't valid.  If that's what in the JSON file then that is what's causing the JSON DataFormat.Error.  You can check yourself here https://jsonlint.com/

A valid version of what you posted is this

 

{
	"fields": [{
			"name": "objectid",
			"type": "esriFieldTypeOID",
			"alias": "OBJECTID",
			"domain": null,
			"editable": false,
			"nullable": false,
			"defaultValue": null,
			"modelName": "objectid"
		},
		{
			"name": "cfa_id",
			"type": "esriFieldTypeString",
			"alias": "CFA_ID",
			"domain": null,
			"editable": true,
			"nullable": true,
			"length": 8000,
			"defaultValue": null,
			"modelName": "CFA_ID"
		},
		{
			"name": "farm_holding_name",
			"type": "esriFieldTypeString",
			"alias": "Farm Holding Name",
			"domain": null,
			"editable": true,
			"nullable": true,
			"length": 8000,
			"defaultValue": null,
			"modelName": "Farm_Holding_Name"
		}
	]
}

 

Where's the JSON being generated?

In my previous reply I asked if you really need to use Python as it appears all you are doing is getting data from a website so you could just use the Web connector in Power Query.

A 403 error is the web server telling you that what you've tried to access is forbidden. I don't see how you can get a valid response in Python/PyCharm but running the same script in PBI gives a 403.

Can you confirm that the URL you are trying to reach is exactly the same in both cases?

Please share the query you are using in PBI.

Phil


If I answered your question please mark my post as the solution.

If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @Anonymous 

It might be that the user agent in PBI is being blocked, or the URL is somehow being malformed inside PBI?

You could try using Fiddler to see what traffic is going between PBI and the website so you can see what PBI is sending.

https://www.telerik.com/fiddler

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Hi Phil,

 

Thanks for the suggestion. I ran the Python script in Pycharm, that worked.

I have never used Fiddler, so wouldn't know how to link to Power BI??

 

I followed Chris Webb's Blog (https://blog.crossjoin.co.uk/2014/03/26/working-with-web-services-in-power-query/), to minimise the number of times entering the API token.

I have the Web.Contents() icon in Power BI Fields tag, but don't see the icon in the Data Sources Settings as shown in the Blog??

 

When I run the Parse JSOn option, I get DataFormat.Error:

DataFormat.Error: We found extra characters at the end of JSON input.
Details:
Value=
Position=0

 

Still can't run the REST URL??

 

 

 

Hi @Anonymous 

Fiddler is a proxy, it intercepts all HTTP(S) traffic between your PC and the internet.  You don't need to link/configure PBI to use it.  Once Fiddler is up and running it will see all web traffic for all programs so you just need to look for the PBI traffic to see what is being sent and received.

That said, I am now confused by a few things in your reply.

I was actually going to suggest you just use a regular Get Data -> Web query as all you Python script seems to be doing is fetching a web page.  Do you have to use Python for this?

In your reply you mention Web.Contents(), so have you already switched to using this in PBI?

 

I have the Web.Contents() icon in Power BI Fields tag, but don't see the icon in the Data Sources Settings as shown in the Blog??

I'm not sure what exactly you are referring to here.  Chris Webb's blog post shows the Data Source Settings that are displayed the first time you connect to web content.  When you first run a web query this should pop up automatically.  So are you now using a web query?  If so can you please share it.

Regarding the JSON error, is the query actually receiving JSON?

Please share your query and the URL you are trying to reach.

Phil


If I answered your question please mark my post as the solution.

If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

My updates didn't appear to get uploaded??

 

My python script imports a JSON file, that contains data that I want to use.

 

 

"fields": [
  {
   "name": "objectid",
   "type": "esriFieldTypeOID",
   "alias": "OBJECTID",
   "domain": null,
   "editable": false,
   "nullable": false,
   "defaultValue": null,
   "modelName": "objectid"
  },
  {
   "name": "cfa_id",
   "type": "esriFieldTypeString",
   "alias": "CFA_ID",
   "domain": null,
   "editable": true,
   "nullable": true,
   "length": 8000,
   "defaultValue": null,
   "modelName": "CFA_ID"
  },
  {
   "name": "farm_holding_name",
   "type": "esriFieldTypeString",
   "alias": "Farm Holding Name",
   "domain": null,
   "editable": true,
   "nullable": true,
   "length": 8000,
   "defaultValue": null,
   "modelName": "Farm_Holding_Name"
  },

 

 

The Table appears in the Query and Dashboard.

 

Value = #"Converted to Table"{47}[Value]

Kept Range = List.Range(Value,0,8)

 

 

The Fields column on the Dashboard only shows the data icon, I cannot see any fields??

dashboard.PNG

 

 

Hi @Anonymous ,

Have you checked the json format is valid before using it in power bi? Invalid json format could casue the data format error.

About HTTP 403 error, you can refer these simliar issues and articles:

  1. 403 Error when trying to access REST API 
  2. Power BI REST API gives 403 error (User does not have access to group) 
  3. FIX: Power BI error Access to the resource is forbidden 

 

In addition, since there is only data field in the table, could you please consider sharing some screenshots in power query about this issue?

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors