Error on user taks: The type or namespace name 'Linq' does not exist in the namespace 'Newtonsoft.Json'

Hi,

I'm trying to create a user task for getting a Gps from address. I tried this in a business process and all was working, now I tried puting this in a user task and I keep getting the following error:
The type or namespace name 'Linq' does not exist in the namespace 'Newtonsoft.Json' for this line:     using Newtonsoft.Json.Linq;
Attached it the full user task code.

namespace Terrasoft.Core.Process.Configuration
{
 
  using Newtonsoft.Json;
    using Newtonsoft.Json.Linq;
	using System;
	using System.Collections.Generic;
	using System.Collections.ObjectModel;
	using System.Globalization;
	using Terrasoft.Common;
	using Terrasoft.Core;
	using Terrasoft.Core.Configuration;
	using Terrasoft.Core.DB;
	using Terrasoft.Core.Entities;
	using Terrasoft.Core.Process;
	using Terrasoft.UI.WebControls.Controls;
    using System.Net;
 
    using System.IO;
 
 
	#region Class: UsrGetGpsFromAddressUserTask
 
	/// <exclude/>
	public partial class UsrGetGpsFromAddressUserTask
	{
 
		#region Methods: Protected
 
		protected override bool InternalExecute(ProcessExecutingContext context) {
          string apiKey = "AIzaSyAxzbYu2BXF7bX0Y37H2ofAQmGfz9KNZJA";
string fullAddress = Get<string>("fullAddress");
string encodedAddress = Uri.EscapeDataString(fullAddress);
string url = $"https://maps.googleapis.com/maps/api/geocode/json?address={encodedAddress}&key={apiKey}";
 
var request = WebRequest.Create(url);
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
using (var reader = new StreamReader(stream))
{
    var json = reader.ReadToEnd();
 
    // Parse the entire JSON response as JObject
    var jsonObj = JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(json);
 
    // Try to get the "results" array safely
    var results = jsonObj["results"] as Newtonsoft.Json.Linq.JArray;
    if (results != null && results.Count > 0)
    {
        var location = results[0]["geometry"]["location"];
        double lat = location.Value<double>("lat");
        double lng = location.Value<double>("lng");
 
        Set<double>("lat", lat);
        Set<double>("lng", lng);
    }
        else
    {
        throw new Exception("No results returned from geocoding API.");
    }
 
}
 
			return true;
		}
 
		#endregion
 
		#region Methods: Public
 
		public override bool CompleteExecuting(params object[] parameters) {
			return base.CompleteExecuting(parameters);
		}
 
		public override void CancelExecuting(params object[] parameters) {
			base.CancelExecuting(parameters);
		}
 
		public override string GetExecutionData() {
			return string.Empty;
		}
 
		public override ProcessElementNotification GetNotificationData() {
			return base.GetNotificationData();
		}
 
		#endregion
 
	}
 
	#endregion
 
}

The package alraedy has the compile into a separate assembly unchecked.

Thanks in advanced,

Chani

Like 0

Like

0 comments
Show all comments